lib/createsend/client.rb in createsend-1.0.4 vs lib/createsend/client.rb in createsend-1.1.0
- old
+ new
@@ -10,10 +10,13 @@
@client_id = client_id
end
# Creates a client.
def self.create(company, contact_name, email, timezone, country)
+ warn "[DEPRECATION] Use person.add or person.update to set the name on a particular person in a client. For now, we will create a default person with the name provided." unless contact_name.to_s == ''
+ warn "[DEPRECATION] Use person.add or person.update to set the email on a particular person in a client. For now, we will create a default person with the email provided." unless email.to_s == ''
+
options = { :body => {
:CompanyName => company,
:ContactName => contact_name,
:EmailAddress => email,
:TimeZone => timezone,
@@ -54,10 +57,27 @@
# Gets the segments belonging to this client.
def segments
response = get 'segments'
response.map{|item| Hashie::Mash.new(item)}
end
+
+ # Gets the people associated with this client
+ def people
+ response = get "people"
+ response.map{|item| Hashie::Mash.new(item)}
+ end
+
+ def get_primary_contact
+ response = get "primarycontact"
+ Hashie::Mash.new(response)
+ end
+
+ def set_primary_contact(email)
+ options = { :query => { :email => email } }
+ response = put "primarycontact", options
+ Hashie::Mash.new(response)
+ end
# Gets this client's suppression list.
def suppressionlist(page=1, page_size=1000, order_field="email", order_direction="asc")
options = { :query => {
:page => page,
@@ -74,28 +94,22 @@
response.map{|item| Hashie::Mash.new(item)}
end
# Sets the basic details for this client.
def set_basics(company, contact_name, email, timezone, country)
+ warn "[DEPRECATION] Use person.update to set name on a particular person in a client. This will fail if there are multiple persons in a client." unless contact_name.to_s == ''
+ warn "[DEPRECATION] Use person.update to set email on a particular person in a client. This will fail if there are multiple persons in a client." unless email.to_s == ''
+
options = { :body => {
:CompanyName => company,
:ContactName => contact_name,
:EmailAddress => email,
:TimeZone => timezone,
:Country => country }.to_json }
put 'setbasics', options
end
- # Sets the access settings for this client.
- def set_access(username, password, access_level)
- options = { :body => {
- :Username => username,
- :Password => password,
- :AccessLevel => access_level }.to_json }
- put 'setaccess', options
- end
-
# Sets the PAYG billing settings for this client.
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)
options = { :body => {
:Currency => currency,
@@ -113,9 +127,21 @@
options = { :body => {
:Currency => currency,
:ClientPays => client_pays,
:MarkupPercentage => markup_percentage }.to_json }
put 'setmonthlybilling', options
+ end
+
+ # THIS METHOD IS DEPRECATED. It should only be used with existing integrations.
+ # Sets the access settings for this client.
+ def set_access(username, password, access_level)
+ warn "[DEPRECATION] `set_access` is deprecated. Use Person.update to set access on a particular person in a client."
+
+ options = { :body => {
+ :Username => username,
+ :Password => password,
+ :AccessLevel => access_level }.to_json }
+ put 'setaccess', options
end
# Deletes this client.
def delete
CreateSend.delete "/clients/#{client_id}.json", {}
\ No newline at end of file