Class: Mixmax
- Inherits:
-
Object
- Object
- Mixmax
- Includes:
- HTTParty
- Defined in:
- lib/mixmax.rb,
lib/mixmax/version.rb
Constant Summary collapse
- VERSION =
"0.1.10"
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #add_to_sequence(sequence_id, recipients:) ⇒ Object
- #change_user_preferences(query: {}) ⇒ Object
-
#initialize(api_key) ⇒ Mixmax
constructor
A new instance of Mixmax.
- #remove_recipient_from_sequence(sequence_id, emails:) ⇒ Object
- #sequence(sequence_id) ⇒ Object
- #sequence_recipients(sequence_id) ⇒ Object
- #sequences(query: {}, all: false) ⇒ Object
- #user_preferences ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Mixmax
Returns a new instance of Mixmax.
9 10 11 12 13 |
# File 'lib/mixmax.rb', line 9 def initialize(api_key) @headers = { 'X-API-Token' => api_key, 'Content-Type' => 'application/json' } end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/mixmax.rb', line 7 def headers @headers end |
Instance Method Details
#add_to_sequence(sequence_id, recipients:) ⇒ Object
37 38 39 |
# File 'lib/mixmax.rb', line 37 def add_to_sequence(sequence_id, recipients:) post "/v1/sequences/#{sequence_id}/recipients", query: recipients end |
#change_user_preferences(query: {}) ⇒ Object
45 46 47 |
# File 'lib/mixmax.rb', line 45 def change_user_preferences(query: {}) patch '/v1/userpreferences/me', body: query end |
#remove_recipient_from_sequence(sequence_id, emails:) ⇒ Object
49 50 51 |
# File 'lib/mixmax.rb', line 49 def remove_recipient_from_sequence(sequence_id, emails:) post "/v1/sequences/#{sequence_id}/cancel", query: { emails: Array(emails) } end |
#sequence(sequence_id) ⇒ Object
29 30 31 |
# File 'lib/mixmax.rb', line 29 def sequence(sequence_id) get "/v1/sequences/#{sequence_id}" end |
#sequence_recipients(sequence_id) ⇒ Object
33 34 35 |
# File 'lib/mixmax.rb', line 33 def sequence_recipients(sequence_id) get "/v1/sequences/#{sequence_id}/recipients" end |
#sequences(query: {}, all: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mixmax.rb', line 17 def sequences(query: {}, all: false) sequences = [] next_param = '' loop do response = get "/v1/sequences/#{next_param}", query: query sequences += response['results'] return sequences unless response['hasNext'] && all next_param = "?next=#{response['next']}" end end |
#user_preferences ⇒ Object
41 42 43 |
# File 'lib/mixmax.rb', line 41 def user_preferences get '/v1/userpreferences/me' end |