mixmax 0.1.4 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6b31fb0624f540f9dfaa1b85082f9fa64b96ce07bbd9a7e7a95f7ec4b313f3f
4
- data.tar.gz: ee9a22950e92e99f1b9875db118adbbb6747b7be16ce989a748735b81c16ff1a
3
+ metadata.gz: 2e142d54d7660249a543181266a988344a188d315d0aae84dc5ce83ae0fb0c58
4
+ data.tar.gz: d4c89f88caa45ad1fe80968c4d278669c502e4a9a72149e15498c74e98dbff38
5
5
  SHA512:
6
- metadata.gz: 5970d375b098415f1ba04dada9f97023ecaa5e6ac2e2602298bc3c6861cc0aaf2062dc80182fb2b99b0bf3e0e3e87a7141094986ce7899fb91796d14748d48c5
7
- data.tar.gz: 4117797998f7991c6b501e8d15b0d8c694e1738a90288c75dce695a7b4753d732ed7edfbf1878e44bf2ce429e1de09db47ce1a6b05cea438856a097718fffa23
6
+ metadata.gz: b5c0e233d03b4943e97508b928f2c57499bbef4ad51d9af4df9f609385299c3dfa0484c518ca7c9f83f73e86bcde4e526434d26d013bf013ec9d437f62c12b9c
7
+ data.tar.gz: ecd1a81f20887f9e81133ea466a91e16005312cceb39f3eb3a03bc0e8c6989e72dbbad8fc8476f8aed7373de577029b20503289d2ea79a8d513ba1016e2c4d73
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mixmax (0.1.3)
4
+ mixmax (0.1.5)
5
5
  httparty (~> 0.16.4)
6
6
 
7
7
  GEM
@@ -40,4 +40,4 @@ DEPENDENCIES
40
40
  rspec (~> 3.0)
41
41
 
42
42
  BUNDLED WITH
43
- 1.16.1
43
+ 1.17.2
data/lib/mixmax.rb CHANGED
@@ -1,28 +1,62 @@
1
- require_relative "mixmax/version"
2
- require "httparty"
1
+ require_relative 'mixmax/version'
2
+ require 'httparty'
3
3
 
4
4
  class Mixmax
5
5
  include HTTParty
6
6
 
7
+ attr_reader :headers
8
+
7
9
  def initialize(api_key)
8
- @headers = { "X-API-Token" => api_key, "Content-Type" => "application/json"}
10
+ @headers = {
11
+ 'X-API-Token' => api_key, 'Content-Type' => 'application/json'
12
+ }
9
13
  end
10
14
 
11
- base_uri "https://api.mixmax.com"
15
+ base_uri 'https://api.mixmax.com'
16
+
17
+ def sequences(query: {}, all: false)
18
+ sequences = []
19
+ next_param = ''
20
+
21
+ loop do
22
+ response = get "/v1/sequences/#{next_param}"
23
+ sequences += response['results']
24
+ return sequences unless response['hasNext'] && all
25
+ next_param = "?next=#{response['next']}"
26
+ end
27
+ end
12
28
 
13
- def sequences(query = {})
14
- self.class.get("/v1/sequences", headers: @headers, query: query).parsed_response["results"]
29
+ def sequence(sequence_id)
30
+ get "/v1/sequences/#{sequence_id}"
15
31
  end
16
32
 
17
- def sequence(id)
18
- self.class.get("/v1/sequences/#{id}", headers: @headers).parsed_response
33
+ def sequence_recipients(sequence_id)
34
+ get "/v1/sequences/#{sequence_id}/recipients"
19
35
  end
20
36
 
21
- def sequence_recipients(id)
22
- self.class.get("/v1/sequences/#{id}/recipients", headers: @headers)
37
+ def add_to_sequence(sequence_id, recipients:)
38
+ post "/v1/sequences/#{sequence_id}/recipients", query: recipients
39
+ end
40
+
41
+ def user_preferences
42
+ get '/v1/userpreferences/me'
43
+ end
44
+
45
+ def change_user_preferences(query: {})
46
+ patch '/v1/userpreferences/me', body: query
47
+ end
48
+
49
+ def remove_recipient_from_sequence(sequence_id, emails:)
50
+ post "/v1/sequences/#{sequence_id}/cancel", query: { emails: Array(emails) }
51
+ end
52
+
53
+ private
54
+
55
+ def get(route, query: {})
56
+ self.class.get(route, headers: headers, body: query.to_json).parsed_response
23
57
  end
24
58
 
25
- def add_to_sequence(id, recipients)
26
- self.class.post("/v1/sequences/#{id}/recipients", headers: @headers, body: recipients)
59
+ def post(route, query: {})
60
+ self.class.post(route, headers: headers, body: query.to_json)
27
61
  end
28
62
  end
@@ -1,3 +1,3 @@
1
1
  class Mixmax
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixmax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Torres
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2019-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 2.7.6
108
+ rubygems_version: 3.0.3
110
109
  signing_key:
111
110
  specification_version: 4
112
111
  summary: A ruby wrapper around MixMax's API