ontraport_api 0.2.0 → 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: 09c473e460cc3c2705a8035e0481535a7f7138c3
4
- data.tar.gz: af3a6c1f4815d4f2fdd33a5a8e949b4b6593123c
3
+ metadata.gz: a97839aad56c249eb9661a4ee7f65adc278de476
4
+ data.tar.gz: 2d4062e746e2874c17707e0e6a43ca81610629bc
5
5
  SHA512:
6
- metadata.gz: 973865d6d5bf7e2de3b4a873e22011368739ae9d0b98fc228728d639b87577472dfc86e2a205919de794ea4d1c0184cda4065c1c418f7a1e0a95be9b314a92e6
7
- data.tar.gz: 1e74c9a5152ec047639906dc2279f1351762ea15ee4a97670ae09cd843c6f56e9fb13f3d86b5e1ced70eeceaa1e3a04cdcf898e1e8ea5b2203f5f2c36017eb12
6
+ metadata.gz: 9b5af05ad83b261edf5c501b179c887062910f8735c1eadc4ad67ce61d4959cc605e207f0a558145e49f22ffc385a7e30e41589818cf7e241ef15d53f481621d
7
+ data.tar.gz: 281a1d41909463b532310537777e39fc1572bbf5660d5931c6e506062b6cd7775d9d5b0eb72f62949604f7eac47577a75939f2231bdadedb5d40d3ba147cd352
data/README.md CHANGED
@@ -22,25 +22,18 @@ Or install it yourself as:
22
22
 
23
23
  $ gem install ontraport_api
24
24
 
25
- ## Usage
26
-
27
- Basic example:
28
25
 
29
- ```ruby
30
- require 'ontraport_api'
31
-
32
- client = OntraportApi::Client.new('app-id','app-key')
26
+ ## Supported APIs
33
27
 
34
- search_results = client.get_contacts({ condition: "email = 'me@jimmyngu.com'" })
35
- puts search_results['data']
28
+ ### Objects
36
29
 
37
- # Error handling
38
- puts search_results['error'] # true if error
39
- puts search_results['message'] # API response body when error
30
+ ```ruby
31
+ client.get_object(id, object_id) # Get an Object's Data
32
+ client.new_object(object_params, object_id) # Create new Object
33
+ client.update_object(id, object_params, object_id) # Update Object Details
34
+ client.get_objects(search_criteria, object_id) # Get List of Objects based on Search Criteria
40
35
  ```
41
36
 
42
- ## Supported APIs
43
-
44
37
  ### Contacts
45
38
 
46
39
  ```ruby
@@ -77,6 +70,66 @@ client.add_sequence_to_contact(sequence_drip_id, contact_id) # Add Sequence t
77
70
 
78
71
  See https://api.ontraport.com/doc/ on details of parameters.
79
72
 
73
+
74
+ ## Usage
75
+
76
+ Basic example:
77
+
78
+ ```ruby
79
+ require 'ontraport_api'
80
+
81
+ client = OntraportApi::Client.new('app-id','app-key')
82
+
83
+ search_results = client.get_contacts("email = 'me@jimmyngu.com' AND lastname = 'Ngu'")
84
+ puts search_results
85
+
86
+ # Error handling
87
+ puts search_results['error'] # true if error
88
+ puts search_results['message'] # API response body when error
89
+ ```
90
+
91
+ Finding Contacts:
92
+
93
+ ```ruby
94
+ contact = client.get_contacts_by_email('me@jimmyngu.com').first
95
+ contact = client.get_contacts_by_city('Kuala Lumpur').first
96
+ contact = client.get_contacts_by_sms_number('+60123456789').first
97
+ ```
98
+
99
+ Create New Contact:
100
+
101
+ ```ruby
102
+ contact = client.new_contact({ firstname: 'Jimmy', lastname: 'Ngu', email: 'me@jimmyngu.com' })
103
+ puts 'Success' if contact['error'].nil?
104
+ ```
105
+
106
+ Adding Tags to Contacts:
107
+
108
+ ```ruby
109
+ tag_name = 'Customer'
110
+ tag = client.get_tags_by_tag_name(tag_name).first
111
+ if tag.nil?
112
+ tag = client.new_tag(tag_name)
113
+ end
114
+
115
+ result = client.add_tags_to_contacts(tag['tag_id'], { ids: contact['id'] })
116
+ puts 'Success' if result['error'].nil?
117
+
118
+ # Multiple tags & contacts
119
+ client.add_tags_to_contacts('<tag_id_1>,<tag_id_2>,<tag_id_3>', { ids: '<contact_id_1>,<contact_id_2>,<contact_id_3>' })
120
+
121
+ # Tag contacts with conditions
122
+ client.add_tags_to_contacts('<tag_id>', "city = 'Kuala Lumpur'" )
123
+ ```
124
+
125
+ Adding Sequence to Contact:
126
+
127
+ ```ruby
128
+ sequence = client.get_sequences_by_name('Sales Funnel')
129
+ result = client.add_sequence_to_contact(sequence['drip_id'], contact['id'])
130
+ puts 'Success' if result['error'].nil?
131
+ ```
132
+
80
133
  ## Contributing
81
134
 
82
135
  1. Fork it ( https://github.com/jimmynguyc/ontraport_api/fork )
@@ -104,6 +157,12 @@ Otherwise, they're missing because I haven't got to them yet. Check the TODO lis
104
157
 
105
158
  ## Release Notes
106
159
 
160
+ #### v0.2.2
161
+ - Added generic Object query
162
+
163
+ #### v0.2.0
164
+ - Return ['data'] as default (breaking v0.1 implementations with ['data'])
165
+
107
166
  #### v0.1.1
108
167
  - Add Contact Sequence API
109
168
 
@@ -0,0 +1,41 @@
1
+ module OntraportApi
2
+ module APIs
3
+ module Objects
4
+ OBJECTS_API_METHODS_AND_PATHS = {
5
+ 'get_object' => [:get, '/object'],
6
+ 'new_object' => [:post, '/objects'],
7
+ 'update_object' => [:put, '/objects'],
8
+ 'get_objects' => [:get, '/objects']
9
+ }
10
+
11
+ def get_object(id, object_id)
12
+ query_objects({id: id}, object_id)
13
+ end
14
+
15
+ def new_object(payload = {}, object_id)
16
+ query_objects(payload, object_id)
17
+ end
18
+
19
+ def update_object(id, payload = {}, object_id)
20
+ query_objects(payload.merge(id: id), object_id)
21
+ end
22
+
23
+ def get_objects(conditions = {}, object_id)
24
+ conditions = { condition: conditions } if conditions.is_a? String
25
+ default_conditions = {
26
+ performAll: true,
27
+ sortDir: 'asc',
28
+ searchNotes: 'true'
29
+ }
30
+ payload = default_conditions.merge(conditions)
31
+ query_objects(payload, object_id)
32
+ end
33
+
34
+ def query_objects(payload, object_id)
35
+ method, path = OBJECTS_API_METHODS_AND_PATHS[caller[0][/`.*'/][1..-2]]
36
+ query(method, path, payload.merge({ objectID: object_id }))
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -3,6 +3,7 @@ require_relative 'apis/contacts'
3
3
  require_relative 'apis/contact_sequences'
4
4
  require_relative 'apis/forms'
5
5
  require_relative 'apis/messages'
6
+ require_relative 'apis/objects'
6
7
  require_relative 'apis/products'
7
8
  require_relative 'apis/sequences'
8
9
  require_relative 'apis/tags'
@@ -19,6 +20,7 @@ module OntraportApi
19
20
  include APIs::Products
20
21
  include APIs::Forms
21
22
  include APIs::Messages
23
+ include APIs::Objects
22
24
  include APIs::Products
23
25
  include APIs::Sequences
24
26
  include APIs::Tags
@@ -1,3 +1,3 @@
1
1
  module OntraportApi
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
data/objectids.txt CHANGED
@@ -1,4 +1,4 @@
1
- 0 - contacts
1
+ 0 - Contacts
2
2
  1 - ?
3
3
  2 - Users
4
4
  3 - ?
@@ -28,4 +28,4 @@
28
28
  27 - ?
29
29
  28 - ?
30
30
  29 - ?
31
- 30 - ?
31
+ 30 - ?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ontraport_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Ngu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,7 @@ files:
83
83
  - lib/ontraport_api/apis/contacts.rb
84
84
  - lib/ontraport_api/apis/forms.rb
85
85
  - lib/ontraport_api/apis/messages.rb
86
+ - lib/ontraport_api/apis/objects.rb
86
87
  - lib/ontraport_api/apis/products.rb
87
88
  - lib/ontraport_api/apis/sequences.rb
88
89
  - lib/ontraport_api/apis/tags.rb
@@ -114,10 +115,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  version: '0'
115
116
  requirements: []
116
117
  rubyforge_project:
117
- rubygems_version: 2.2.2
118
+ rubygems_version: 2.4.5
118
119
  signing_key:
119
120
  specification_version: 4
120
121
  summary: Ruby Client for Ontraport's JSON API
121
122
  test_files:
122
123
  - test/ontraport_api/client_test.rb
123
124
  - test/test_helper.rb
125
+ has_rdoc: