Class: CreateSend::Client
- Inherits:
-
Object
- Object
- CreateSend::Client
- Defined in:
- lib/createsend/client.rb
Overview
Represents a client and associated functionality.
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
Class Method Summary collapse
-
.create(company, contact_name, email, timezone, country) ⇒ Object
Creates a client.
Instance Method Summary collapse
-
#campaigns ⇒ Object
Gets the sent campaigns belonging to this client.
-
#delete ⇒ Object
Deletes this client.
-
#details ⇒ Object
Gets the details of this client.
-
#drafts ⇒ Object
Gets the draft campaigns belonging to this client.
-
#initialize(client_id) ⇒ Client
constructor
A new instance of Client.
-
#lists ⇒ Object
Gets the subscriber lists belonging to this client.
-
#segments ⇒ Object
Gets the segments belonging to this client.
-
#set_access(username, password, access_level) ⇒ Object
Sets the access settings for this client.
-
#set_basics(company, contact_name, email, timezone, country) ⇒ Object
Sets the basic details for this client.
-
#set_monthly_billing(currency, client_pays, markup_percentage) ⇒ Object
Sets the monthly billing settings for this client.
-
#set_payg_billing(currency, can_purchase_credits, client_pays, markup_percentage, markup_on_delivery = 0, markup_per_recipient = 0, markup_on_design_spam_test = 0) ⇒ Object
Sets the PAYG billing settings for this client.
-
#suppressionlist(page = 1, page_size = 1000, order_field = "email", order_direction = "asc") ⇒ Object
Gets this client’s suppression list.
-
#templates ⇒ Object
Gets the templates belonging to this client.
Constructor Details
#initialize(client_id) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/createsend/client.rb', line 9 def initialize(client_id) @client_id = client_id end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/createsend/client.rb', line 7 def client_id @client_id end |
Class Method Details
.create(company, contact_name, email, timezone, country) ⇒ Object
Creates a client.
14 15 16 17 18 19 20 21 22 |
# File 'lib/createsend/client.rb', line 14 def self.create(company, contact_name, email, timezone, country) = { :body => { :CompanyName => company, :ContactName => contact_name, :EmailAddress => email, :TimeZone => timezone, :Country => country }.to_json } CreateSend.post "/clients.json", end |
Instance Method Details
#campaigns ⇒ Object
Gets the sent campaigns belonging to this client.
31 32 33 34 |
# File 'lib/createsend/client.rb', line 31 def campaigns response = get 'campaigns' response.map{|item| Hashie::Mash.new(item)} end |
#delete ⇒ Object
Deletes this client.
115 116 117 |
# File 'lib/createsend/client.rb', line 115 def delete CreateSend.delete "/clients/#{client_id}.json", {} end |
#details ⇒ Object
Gets the details of this client.
25 26 27 28 |
# File 'lib/createsend/client.rb', line 25 def details response = CreateSend.get "/clients/#{client_id}.json", {} Hashie::Mash.new(response) end |
#drafts ⇒ Object
Gets the draft campaigns belonging to this client.
37 38 39 40 |
# File 'lib/createsend/client.rb', line 37 def drafts response = get 'drafts' response.map{|item| Hashie::Mash.new(item)} end |
#lists ⇒ Object
Gets the subscriber lists belonging to this client.
43 44 45 46 |
# File 'lib/createsend/client.rb', line 43 def lists response = get 'lists' response.map{|item| Hashie::Mash.new(item)} end |
#segments ⇒ Object
Gets the segments belonging to this client.
49 50 51 52 |
# File 'lib/createsend/client.rb', line 49 def segments response = get 'segments' response.map{|item| Hashie::Mash.new(item)} end |
#set_access(username, password, access_level) ⇒ Object
Sets the access settings for this client.
83 84 85 86 87 88 89 |
# File 'lib/createsend/client.rb', line 83 def set_access(username, password, access_level) = { :body => { :Username => username, :Password => password, :AccessLevel => access_level }.to_json } put 'setaccess', end |
#set_basics(company, contact_name, email, timezone, country) ⇒ Object
Sets the basic details for this client.
72 73 74 75 76 77 78 79 80 |
# File 'lib/createsend/client.rb', line 72 def set_basics(company, contact_name, email, timezone, country) = { :body => { :CompanyName => company, :ContactName => contact_name, :EmailAddress => email, :TimeZone => timezone, :Country => country }.to_json } put 'setbasics', end |
#set_monthly_billing(currency, client_pays, markup_percentage) ⇒ Object
Sets the monthly billing settings for this client.
106 107 108 109 110 111 112 |
# File 'lib/createsend/client.rb', line 106 def set_monthly_billing(currency, client_pays, markup_percentage) = { :body => { :Currency => currency, :ClientPays => client_pays, :MarkupPercentage => markup_percentage }.to_json } put 'setmonthlybilling', end |
#set_payg_billing(currency, can_purchase_credits, client_pays, markup_percentage, markup_on_delivery = 0, markup_per_recipient = 0, markup_on_design_spam_test = 0) ⇒ Object
Sets the PAYG billing settings for this client.
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/createsend/client.rb', line 92 def set_payg_billing(currency, can_purchase_credits, client_pays, markup_percentage, markup_on_delivery=0, markup_per_recipient=0, markup_on_design_spam_test=0) = { :body => { :Currency => currency, :CanPurchaseCredits => can_purchase_credits, :ClientPays => client_pays, :MarkupPercentage => markup_percentage, :MarkupOnDelivery => markup_on_delivery, :MarkupPerRecipient => markup_per_recipient, :MarkupOnDesignSpamTest => markup_on_design_spam_test }.to_json } put 'setpaygbilling', end |
#suppressionlist(page = 1, page_size = 1000, order_field = "email", order_direction = "asc") ⇒ Object
Gets this client’s suppression list.
55 56 57 58 59 60 61 62 63 |
# File 'lib/createsend/client.rb', line 55 def suppressionlist(page=1, page_size=1000, order_field="email", order_direction="asc") = { :query => { :page => page, :pagesize => page_size, :orderfield => order_field, :orderdirection => order_direction } } response = get 'suppressionlist', Hashie::Mash.new(response) end |
#templates ⇒ Object
Gets the templates belonging to this client.
66 67 68 69 |
# File 'lib/createsend/client.rb', line 66 def templates response = get 'templates' response.map{|item| Hashie::Mash.new(item)} end |