maropost_api 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af14a78b1044d7b675900a4b9e6adb328e535ccd
4
- data.tar.gz: a77e640922f64085f6cdf62603d97aaa9f7a2172
3
+ metadata.gz: 7dc66c3cbcc15141e340c383214139b27cfc3281
4
+ data.tar.gz: ef13a2dca9de1962188db892f36eec7673b3dfdd
5
5
  SHA512:
6
- metadata.gz: 11fcf35c5f59396621fdcd098d0862fb0f30a3b2a12f23d5dc695d5750de212b1ccdb74b46f133dba5ba0053c413a033e8e5a8285edc39808428580601586c0f
7
- data.tar.gz: 93b8350e09411d8b9af96ba944b68a63f60eea76d1a043fc73dfb6d229733d201dc931c0e8700b9efb6895b826b7a3525e01a515b1282fe5405b61e1cc13a893
6
+ metadata.gz: b615b3dd47c64109c0d98751b2f32916ae198463d0004b3393bbb0695e5e85595c0c66a9ad2772ba618fdde7ce2756d8431031cddcb5e6d8a7318b92731234f4
7
+ data.tar.gz: dd4b7add3fad5b892ce2de342eba5ed7f1737e14c5223db13503dafc4739534fd8d38213a64d5fdaa7964a63f2b3dcdca74ce1f5a1bfaf5f83725d870f4ef558
@@ -4,7 +4,6 @@ require "maropost_api/request"
4
4
  require "maropost_api/errors"
5
5
  require "maropost_api/response"
6
6
  require "maropost_api/parser/entity_parser"
7
- require "maropost_api/parser/message_body_parser"
8
7
  require "maropost_api/client"
9
8
  require "maropost_api/contacts"
10
9
  require "maropost_api/workflows"
@@ -1,8 +1,8 @@
1
1
  module MaropostApi
2
2
  class Contacts
3
- def initialize(request:)
3
+ def initialize(request:, parser: Parser::EntityParser.new)
4
4
  @request = request
5
- @parser = Parser::EntityParser.new
5
+ @parser = parser
6
6
  end
7
7
 
8
8
  def find_by_email(email:)
@@ -29,5 +29,7 @@ module MaropostApi
29
29
  response = @request.put(endpoint: "/contacts/unsubscribe_all.json?contact[email]=#{CGI.escape(email)}")
30
30
  Response.new(response: response, parser: @parser).call
31
31
  end
32
+
33
+ alias :upsert :create
32
34
  end
33
35
  end
@@ -1,3 +1,3 @@
1
1
  module MaropostApi
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -1,24 +1,23 @@
1
1
  module MaropostApi
2
2
  class Workflows
3
- def initialize(request:)
3
+ def initialize(request:, parser: Parser::EntityParser.new)
4
4
  @request = request
5
- @body_parser = Parser::MessageBodyParser.new
6
- @entity_parser = Parser::EntityParser.new
5
+ @parser = parser
7
6
  end
8
7
 
9
8
  def stop(workflow_id:, contact_id:)
10
9
  response = @request.put(endpoint: "/workflows/#{workflow_id}/stop/#{contact_id}.json")
11
- Response.new(response: response, parser: @body_parser).call
10
+ Response.new(response: response, parser: @parser).call
12
11
  end
13
12
 
14
13
  def start(workflow_id:, contact_id:)
15
14
  response = @request.put(endpoint: "/workflows/#{workflow_id}/start/#{contact_id}.json")
16
- Response.new(response: response, parser: @body_parser).call
15
+ Response.new(response: response, parser: @parser).call
17
16
  end
18
17
 
19
18
  def reset(workflow_id:, contact_id:)
20
19
  response = @request.put(endpoint: "/workflows/#{workflow_id}/reset/#{contact_id}.json")
21
- Response.new(response: response, parser: @entity_parser).call
20
+ Response.new(response: response, parser: @parser).call
22
21
  end
23
22
  end
24
23
  end
data/readme.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/maropost_api.svg)](https://badge.fury.io/rb/maropost_api)
2
+
1
3
  # MaropostApi
2
4
 
3
5
  A simple ruby wrapper for Maropost (http://maropost.com/) API.
@@ -37,6 +39,9 @@ client.contacts.add_to_list(list_ids: '<id>', params: {email: 'test@example.com'
37
39
  # To create a contact without any lists
38
40
  client.contacts.create(params: {email: 'test@example.com'})
39
41
 
42
+ # Upsert, alias for contacts.create
43
+ client.contacts.upsert(params: {email: 'test@example.com'})
44
+
40
45
  # To update a contact
41
46
  client.contacts.update(contact_id: '<id>', params: {email: 'test@example.com', first_name: 'test-updated'})
42
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maropost_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hossein Toussi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-07-21 00:00:00.000000000 Z
12
+ date: 2016-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -143,7 +143,6 @@ files:
143
143
  - lib/maropost_api/contacts.rb
144
144
  - lib/maropost_api/errors.rb
145
145
  - lib/maropost_api/parser/entity_parser.rb
146
- - lib/maropost_api/parser/message_body_parser.rb
147
146
  - lib/maropost_api/request.rb
148
147
  - lib/maropost_api/response.rb
149
148
  - lib/maropost_api/version.rb
@@ -1,9 +0,0 @@
1
- module MaropostApi
2
- module Parser
3
- class MessageBodyParser
4
- def call(response)
5
- Hashie::Mash.new(message: response.body)
6
- end
7
- end
8
- end
9
- end