Skip to content

Commit

Permalink
Merge pull request #3 from jonuts/master
Browse files Browse the repository at this point in the history
thanks your contribution.
  • Loading branch information
frozenfung committed Mar 1, 2015
2 parents 0339ed0 + 41ccafb commit 3f184d7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/cindy/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ def initialize(sendy_url, api_key = nil)
@key = api_key || ENV['SENDY_API_KEY']
end

def create_campaign(opts={})
post_opts = {}
req_opts = %i(from_name from_email reply_to subject html_text)
optional_opts = %i(plain_text list_ids brand_id send_campaign)

req_opts.each do |opt|
post_opts[opt] = opts.delete(opt) || raise(ArgumentError, "opt :#{opt} required")
end
post_opts.merge!(Hash[optional_opts.zip(opts.values_at(*optional_opts))])
post_opts[:api_key] = @key

response = connection.post "api/campaigns/create.php" do |req|
req.body = post_opts
end

response.body
end

def subscribe(list_id, email, name = nil)
response = connection.post "subscribe" do |req|
params = {list: list_id, email: email, boolean: true}
Expand Down

0 comments on commit 3f184d7

Please sign in to comment.