infusionsoft 1.3.0a → 1.3.5

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
  SHA256:
3
- metadata.gz: 8a7e9e07a053e797587d945bbd72ae311eec9b3aac0eb5bebda59fe9512c7ccb
4
- data.tar.gz: 28b23ae6b99cf7e146b476b922613b272c4f5acf0605bb5ea755eff0cd01e5ce
3
+ metadata.gz: ea5036f0847c9f8d2d27b105450d9f7f244fc3c8afc82a9df65a5dd3dfd2259c
4
+ data.tar.gz: 225a3bc76cd0d2dbf2834709fd515d56145bc8ebcacde1adc5cf861d79d6e90c
5
5
  SHA512:
6
- metadata.gz: b8934f77b9f5e1d94bc9a9f24270bbf948f12491a1a4f0134e9a519d6a4c4b03a1b1c13f91b2ffa0ffff8b09504ee1577951ea3e4fb8c488c4404612517ece1c
7
- data.tar.gz: a339f6b7bee9de9375190aa4fcf0b1df4d94c2fe9624b36f55b934c347f399650cb946b9a0cb53a4a6aff5882694ab87059682c604b91b516296012db26fda73
6
+ metadata.gz: 3ecd5f2ee7588c842b4e83355fe3c9abd154e38cd772f408ce32ffc269feca4c3b8640f8b8961d5f4af58400ca38c93a19e7a6766843e49d4b4fb5a6d1fe8e60
7
+ data.tar.gz: fb4ee7abf586a9160c10e1d8ee1e3c7ce51454f89f0948a4dae773e754fb246904a722721490208171a762e2764e4cd142e25d65817666d6bb3ab5ced776daee
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.5
5
- - 2.2.2
6
- - 2.3.4
7
- # - 2.4.1 need to do more testing
3
+ - 2.3.8
4
+ - 2.4.5
5
+ - 2.5.3
6
+ - 2.6.1
8
7
  - jruby-20mode # JRuby in 2.0 mode
data/README.md CHANGED
@@ -98,7 +98,7 @@ features.
98
98
  ## <a name="rubies">Supported Rubies</a>
99
99
  This library aims to support the following Ruby implementations:
100
100
 
101
- * Ruby >= 2.0
101
+ * Ruby >= 2.3.8
102
102
  * [JRuby](http://www.jruby.org/)
103
103
  * [Rubinius](http://rubini.us/)
104
104
  * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
@@ -14,6 +14,9 @@ Gem::Specification.new do |gem|
14
14
  gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
15
15
  gem.add_development_dependency 'rake'
16
16
 
17
+ gem.add_dependency "xmlrpc"
18
+ gem.add_dependency "rest-client"
19
+
17
20
  gem.version = Infusionsoft::VERSION.dup
18
21
  end
19
22
 
@@ -2,6 +2,7 @@ require 'infusionsoft/api'
2
2
  require 'infusionsoft/client'
3
3
  require 'infusionsoft/configuration'
4
4
  require 'infusionsoft/api_logger'
5
+ require 'infusionsoft/rest/token'
5
6
 
6
7
  module Infusionsoft
7
8
  extend Configuration
@@ -15,7 +15,7 @@ module Infusionsoft
15
15
  # @return [Array] all claw backs for the given affiliate that have occurred within the date
16
16
  # range specified
17
17
  def affiliate_clawbacks(affiliate_id, start_date, end_date)
18
- response = get('APIAffiliateService.affClawbacks', affiliate_id, start_date, end_date)
18
+ response = xmlrpc('APIAffiliateService.affClawbacks', affiliate_id, start_date, end_date)
19
19
  end
20
20
 
21
21
  # Used to retrieve all commissions for a specific affiliate within a date range.
@@ -26,7 +26,7 @@ module Infusionsoft
26
26
  # @return [Array] all sales commissions for the given affiliate earned within the date range
27
27
  # specified
28
28
  def affiliate_commissions(affiliate_id, start_date, end_date)
29
- response = get('APIAffiliateService.affCommissions', affiliate_id, start_date, end_date)
29
+ response = xmlrpc('APIAffiliateService.affCommissions', affiliate_id, start_date, end_date)
30
30
  end
31
31
 
32
32
  # Used to retrieve all payments for a specific affiliate within a date range.
@@ -36,7 +36,7 @@ module Infusionsoft
36
36
  # @param [Date] end_date
37
37
  # @return [Array] a list of rows, each row is a single payout
38
38
  def affiliate_payouts(affiliate_id, start_date, end_date)
39
- response = get('APIAffiliateService.affPayouts', affiliate_id, start_date, end_date)
39
+ response = xmlrpc('APIAffiliateService.affPayouts', affiliate_id, start_date, end_date)
40
40
  end
41
41
 
42
42
  # This method is used to retrieve all commissions for a specific affiliate within a date range.
@@ -45,7 +45,7 @@ module Infusionsoft
45
45
  # @return [Array] all sales commissions for the given affiliate earned within the date range
46
46
  # specified
47
47
  def affiliate_running_totals(affiliate_list)
48
- response = get('APIAffiliateService.affRunningTotals', affiliate_list)
48
+ response = xmlrpc('APIAffiliateService.affRunningTotals', affiliate_list)
49
49
  end
50
50
 
51
51
  # Used to retrieve a summary of statistics for a list of affiliates.
@@ -55,7 +55,7 @@ module Infusionsoft
55
55
  # @param [Date] end_date
56
56
  # @return [Array<Hash>] a summary of the affiliates information for a specified date range
57
57
  def affiliate_summary(affiliate_list, start_date, end_date)
58
- response = get('APIAffiliateService.affSummary', affiliate_list, start_date, end_date)
58
+ response = xmlrpc('APIAffiliateService.affSummary', affiliate_list, start_date, end_date)
59
59
  end
60
60
  end
61
61
  end
@@ -12,7 +12,7 @@ module Infusionsoft
12
12
  # @example
13
13
  # { :Email => 'test@test.com', :FirstName => 'first_name', :LastName => 'last_name' }, 'New Signup'
14
14
  def contact_add(data, optin_status=nil)
15
- contact_id = get('ContactService.add', data)
15
+ contact_id = xmlrpc('ContactService.add', data)
16
16
  email = data['Email'] || data[:Email]
17
17
  if optin_status && email; email_optin(email, optin_status); end
18
18
  return contact_id
@@ -23,7 +23,7 @@ module Infusionsoft
23
23
  # @param [Integer] contact_id
24
24
  # @param [Integer] duplicate_contact_id
25
25
  def contact_merge(contact_id, duplicate_contact_id)
26
- response = get('ContactService.merge', contact_id, duplicate_contact_id)
26
+ response = xmlrpc('ContactService.merge', contact_id, duplicate_contact_id)
27
27
  end
28
28
 
29
29
  # Adds or updates a contact record based on matching data
@@ -37,7 +37,7 @@ module Infusionsoft
37
37
  # @example
38
38
  # { :Email => 'test@test.com', :FirstName => 'first_name', :LastName => 'last_name' }, 'Email', 'New Signup'
39
39
  def contact_add_with_dup_check(data, check_type, optin_status=nil)
40
- contact_id = get('ContactService.addWithDupCheck', data, check_type)
40
+ contact_id = xmlrpc('ContactService.addWithDupCheck', data, check_type)
41
41
  email = data['Email'] || data[:Email]
42
42
  if optin_status && email; email_optin(email, optin_status); end
43
43
  return contact_id
@@ -53,7 +53,7 @@ module Infusionsoft
53
53
  # @example
54
54
  # { :FirstName => 'first_name', :StreetAddress1 => '123 N Street' }, 'New Signup'
55
55
  def contact_update(contact_id, data, optin_status=nil)
56
- contact_id = get('ContactService.update', contact_id, data)
56
+ contact_id = xmlrpc('ContactService.update', contact_id, data)
57
57
  email = data['Email'] || data[:Email]
58
58
  if optin_status && email; email_optin(email, optin_status); end
59
59
  return contact_id
@@ -67,7 +67,7 @@ module Infusionsoft
67
67
  # @example this is what you would get back
68
68
  # { "FirstName" => "John", "LastName" => "Doe" }
69
69
  def contact_load(id, selected_fields)
70
- response = get('ContactService.load', id, selected_fields)
70
+ response = xmlrpc('ContactService.load', id, selected_fields)
71
71
  end
72
72
 
73
73
  # Finds all contacts with the supplied email address in any of the three contact record email
@@ -77,7 +77,7 @@ module Infusionsoft
77
77
  # @param [Array] selected_fields the list of fields you want with it's data
78
78
  # @return [Array<Hash>] the list of contacts with it's fields and data
79
79
  def contact_find_by_email(email, selected_fields)
80
- response = get('ContactService.findByEmail', email, selected_fields)
80
+ response = xmlrpc('ContactService.findByEmail', email, selected_fields)
81
81
  end
82
82
 
83
83
  # Adds a contact to a follow-up sequence (campaigns were the original name of follow-up sequences).
@@ -87,7 +87,7 @@ module Infusionsoft
87
87
  # @return [Boolean] returns true/false if the contact was added to the follow-up sequence
88
88
  # successfully
89
89
  def contact_add_to_campaign(contact_id, campaign_id)
90
- response = get('ContactService.addToCampaign', contact_id, campaign_id)
90
+ response = xmlrpc('ContactService.addToCampaign', contact_id, campaign_id)
91
91
  end
92
92
 
93
93
  # Returns the Id number of the next follow-up sequence step for the given contact.
@@ -97,7 +97,7 @@ module Infusionsoft
97
97
  # @return [Integer] id number of the next unfishished step in the given follow up sequence
98
98
  # for the given contact
99
99
  def contact_get_next_campaign_step(contact_id, campaign_id)
100
- response = get('ContactService.getNextCampaignStep', contact_id, campaign_id)
100
+ response = xmlrpc('ContactService.getNextCampaignStep', contact_id, campaign_id)
101
101
  end
102
102
 
103
103
  # Pauses a follow-up sequence for the given contact record
@@ -106,7 +106,7 @@ module Infusionsoft
106
106
  # @param [Integer] campaign_id
107
107
  # @return [Boolean] returns true/false if the sequence was paused
108
108
  def contact_pause_campaign(contact_id, campaign_id)
109
- response = get('ContactService.pauseCampaign', contact_id, campaign_id)
109
+ response = xmlrpc('ContactService.pauseCampaign', contact_id, campaign_id)
110
110
  end
111
111
 
112
112
  # Removes a follow-up sequence from a contact record
@@ -115,7 +115,7 @@ module Infusionsoft
115
115
  # @param [Integer] campaign_id
116
116
  # @return [Boolean] returns true/false if removed
117
117
  def contact_remove_from_campaign(contact_id, campaign_id)
118
- response = get('ContactService.removeFromCampaign', contact_id, campaign_id)
118
+ response = xmlrpc('ContactService.removeFromCampaign', contact_id, campaign_id)
119
119
  end
120
120
 
121
121
  # Resumes a follow-up sequence that has been stopped/paused for a given contact.
@@ -124,7 +124,7 @@ module Infusionsoft
124
124
  # @param [Ingeger] campaign_id
125
125
  # @return [Boolean] returns true/false if sequence was resumed
126
126
  def contact_resume_campaign(contact_id, campaign_id)
127
- response = get('ConactService.resumeCampaignForContact', contact_id, campaign_id)
127
+ response = xmlrpc('ConactService.resumeCampaignForContact', contact_id, campaign_id)
128
128
  end
129
129
 
130
130
  # Immediately performs the given follow-up sequence step_id for the given contacts.
@@ -133,7 +133,7 @@ module Infusionsoft
133
133
  # @param [Integer] ) step_id
134
134
  # @return [Boolean] returns true/false if the step was rescheduled
135
135
  def contact_reschedule_campaign_step(list_of_contacts, step_id)
136
- response = get('ContactService.reschedulteCampaignStep', list_of_contacts, step_id)
136
+ response = xmlrpc('ContactService.reschedulteCampaignStep', list_of_contacts, step_id)
137
137
  end
138
138
 
139
139
  # Removes a tag from a contact (groups were the original name of tags).
@@ -142,7 +142,7 @@ module Infusionsoft
142
142
  # @param [Integer] group_id
143
143
  # @return [Boolean] returns true/false if tag was removed successfully
144
144
  def contact_remove_from_group(contact_id, group_id)
145
- response = get('ContactService.removeFromGroup', contact_id, group_id)
145
+ response = xmlrpc('ContactService.removeFromGroup', contact_id, group_id)
146
146
  end
147
147
 
148
148
  # Adds a tag to a contact
@@ -151,7 +151,7 @@ module Infusionsoft
151
151
  # @param [Integer] group_id
152
152
  # @return [Boolean] returns true/false if the tag was added successfully
153
153
  def contact_add_to_group(contact_id, group_id)
154
- response = get('ContactService.addToGroup', contact_id, group_id)
154
+ response = xmlrpc('ContactService.addToGroup', contact_id, group_id)
155
155
  end
156
156
 
157
157
  # Runs an action set on a given contact record
@@ -163,20 +163,20 @@ module Infusionsoft
163
163
  # [{ 'Action' => 'Create Task', 'Message' => 'task1 (Task) sent successfully', 'isError' =>
164
164
  # nil }]
165
165
  def contact_run_action_set(contact_id, action_set_id)
166
- response = get('ContactService.runActionSequence', contact_id, action_set_id)
166
+ response = xmlrpc('ContactService.runActionSequence', contact_id, action_set_id)
167
167
  end
168
168
 
169
169
  def contact_link_contact(remoteApp, remoteId, localId)
170
- response = get('ContactService.linkContact', remoteApp, remoteId, localId)
170
+ response = xmlrpc('ContactService.linkContact', remoteApp, remoteId, localId)
171
171
  end
172
172
 
173
173
 
174
174
  def contact_locate_contact_link(locate_map_id)
175
- response = get('ContactService.locateContactLink', locate_map_id)
175
+ response = xmlrpc('ContactService.locateContactLink', locate_map_id)
176
176
  end
177
177
 
178
178
  def contact_mark_link_updated(locate_map_id)
179
- response = get('ContactService.markLinkUpdated', locate_map_id)
179
+ response = xmlrpc('ContactService.markLinkUpdated', locate_map_id)
180
180
  end
181
181
 
182
182
  # Creates a new recurring order for a contact.
@@ -189,7 +189,7 @@ module Infusionsoft
189
189
  # @param [Integer] affiliate_id
190
190
  def contact_add_recurring_order(contact_id, allow_duplicate, cprogram_id, merchant_account_id,
191
191
  credit_card_id, affiliate_id, days_till_charge)
192
- response = get('ContactService.addRecurringOrder', contact_id, allow_duplicate, cprogram_id,
192
+ response = xmlrpc('ContactService.addRecurringOrder', contact_id, allow_duplicate, cprogram_id,
193
193
  merchant_account_id, credit_card_id, affiliate_id, days_till_charge)
194
194
  end
195
195
 
@@ -200,7 +200,7 @@ module Infusionsoft
200
200
  # @param [Integer] action_set_id
201
201
  # @param [Hash] data
202
202
  def contact_run_action_set_with_params(contact_id, action_set_id, data)
203
- response = get('ContactService.runActionSequence', contact_id, action_set_id, data)
203
+ response = xmlrpc('ContactService.runActionSequence', contact_id, action_set_id, data)
204
204
  end
205
205
 
206
206
  end
@@ -1,7 +1,7 @@
1
1
  module Infusionsoft
2
2
  class Client
3
- # CreditCardSubmission service is used to obtain a token that is to be submitted
4
- # through a form when adding a credit card. In accordance with PCI compliance,
3
+ # CreditCardSubmission service is used to obtain a token that is to be submitted
4
+ # through a form when adding a credit card. In accordance with PCI compliance,
5
5
  # adding credit cards through the API will no longer be supported.
6
6
  module CreditCard
7
7
 
@@ -12,11 +12,11 @@ module Infusionsoft
12
12
  # @param [String] url that will be redirected to upon successfully adding card
13
13
  # @param [String] url that will be redirected to when there is a failure upon adding card
14
14
  def credit_card_request_token(contact_id, success_url, failure_url)
15
- response = get('CreditCardSubmissionService.requestSubmissionToken', contact_id, success_url, failure_url)
15
+ response = xmlrpc('CreditCardSubmissionService.requestSubmissionToken', contact_id, success_url, failure_url)
16
16
  end
17
17
 
18
18
  def credit_card_lookup_by_token(token)
19
- response = get('CreditCardSubmissionService.requestCreditCardId', token)
19
+ response = xmlrpc('CreditCardSubmissionService.requestCreditCardId', token)
20
20
  end
21
21
 
22
22
  end
@@ -9,7 +9,7 @@ module Infusionsoft
9
9
  # @param [Hash] data the fields and it's data
10
10
  # @return [Integer] returns the id of the record added
11
11
  def data_add(table, data)
12
- response = get('DataService.add', table, data)
12
+ response = xmlrpc('DataService.add', table, data)
13
13
  end
14
14
 
15
15
  # This method will load a record from the database given the primary key.
@@ -21,7 +21,7 @@ module Infusionsoft
21
21
  # @example
22
22
  # { "FirstName" => "John", "LastName" => "Doe" }
23
23
  def data_load(table, id, selected_fields)
24
- response = get('DataService.load', table, id, selected_fields)
24
+ response = xmlrpc('DataService.load', table, id, selected_fields)
25
25
  end
26
26
 
27
27
  # Updates the specified record (indicated by ID) with the data provided.
@@ -33,7 +33,7 @@ module Infusionsoft
33
33
  # @example
34
34
  # { :FirstName => 'John', :Email => 'test@test.com' }
35
35
  def data_update(table, id, data)
36
- response = get('DataService.update', table, id, data)
36
+ response = xmlrpc('DataService.update', table, id, data)
37
37
  end
38
38
 
39
39
  # Deletes the record (specified by id) in the given table from the database.
@@ -42,7 +42,7 @@ module Infusionsoft
42
42
  # @param [Integer] id
43
43
  # @return [Boolean] returns true/false if the record was successfully deleted
44
44
  def data_delete(table, id)
45
- response = get('DataService.delete', table, id)
45
+ response = xmlrpc('DataService.delete', table, id)
46
46
  end
47
47
 
48
48
  # This will locate all records in a given table that match the criteria for a given field.
@@ -55,7 +55,7 @@ module Infusionsoft
55
55
  # @param [Array] selected_fields
56
56
  # @return [Array<Hash>] returns the array of records with a hash of the fields and values
57
57
  def data_find_by_field(table, limit, page, field_name, field_value, selected_fields)
58
- response = get('DataService.findByField', table, limit, page, field_name,
58
+ response = xmlrpc('DataService.findByField', table, limit, page, field_name,
59
59
  field_value, selected_fields)
60
60
  end
61
61
 
@@ -68,7 +68,7 @@ module Infusionsoft
68
68
  # @param [Array] selected_fields the fields and values you want back
69
69
  # @return [Array<Hash>] the fields and associated values
70
70
  def data_query(table, limit, page, data, selected_fields)
71
- response = get('DataService.query', table, limit, page, data, selected_fields)
71
+ response = xmlrpc('DataService.query', table, limit, page, data, selected_fields)
72
72
  end
73
73
 
74
74
  # Queries records in a given table to find matches on certain fields.
@@ -82,7 +82,7 @@ module Infusionsoft
82
82
  # @param [Boolean] true ascending, false descending
83
83
  # @return [Array<Hash>] the fields and associated values
84
84
  def data_query_order_by(table, limit, page, data, selected_fields, by, ascending)
85
- response = get('DataService.query', table, limit, page, data, selected_fields, by, ascending)
85
+ response = xmlrpc('DataService.query', table, limit, page, data, selected_fields, by, ascending)
86
86
  end
87
87
 
88
88
  # Adds a custom field to Infusionsoft
@@ -94,7 +94,7 @@ module Infusionsoft
94
94
  # @param [Integer] header_id see notes here
95
95
  # http://help.infusionsoft.com/developers/services-methods/data/addCustomField
96
96
  def data_add_custom_field(field_type, name, data_type, header_id)
97
- response = get('DataService.addCustomField', field_type, name, data_type, header_id)
97
+ response = xmlrpc('DataService.addCustomField', field_type, name, data_type, header_id)
98
98
  end
99
99
 
100
100
  # Authenticate an Infusionsoft username and password(md5 hash). If the credentials match
@@ -105,7 +105,7 @@ module Infusionsoft
105
105
  # @param [String] password
106
106
  # @return [Integer] id of the authenticated user
107
107
  def data_authenticate_user(username, password)
108
- response = get('DataService.authenticateUser', username, password)
108
+ response = xmlrpc('DataService.authenticateUser', username, password)
109
109
  end
110
110
 
111
111
  # This method will return back the data currently configured in a user configured
@@ -119,7 +119,7 @@ module Infusionsoft
119
119
  # before the underscore is the module name. "Contact" in this example. The portion after the
120
120
  # 0 is the setting name, "optiontypes" in this example.
121
121
  def data_get_app_setting(module_name, setting)
122
- response = get('DataService.getAppSetting', module_name, setting)
122
+ response = xmlrpc('DataService.getAppSetting', module_name, setting)
123
123
  end
124
124
 
125
125
  # Returns a temporary API key if given a valid Vendor key and user credentials.
@@ -129,7 +129,7 @@ module Infusionsoft
129
129
  # @param [String] password_hash an md5 hash of users password
130
130
  # @return [String] temporary API key
131
131
  def data_get_temporary_key(vendor_key, username, password_hash)
132
- response = get('DataService.getTemporaryKey', username, password_hash)
132
+ response = xmlrpc('DataService.getTemporaryKey', username, password_hash)
133
133
  end
134
134
 
135
135
  # Updates a custom field. Every field can have it’s display name and group id changed,
@@ -139,7 +139,7 @@ module Infusionsoft
139
139
  # @param [Hash] field_values
140
140
  # @return [Boolean] returns true/false if it was updated
141
141
  def data_update_custom_field(field_id, field_values)
142
- response = get('DataService.updateCustomField', field_id, field_values)
142
+ response = xmlrpc('DataService.updateCustomField', field_id, field_values)
143
143
  end
144
144
  end
145
145
  end
@@ -21,7 +21,7 @@ module Infusionsoft
21
21
  # @param [String] merge_context can be Contact, ServiceCall, Opportunity, CreditCard
22
22
  def email_add(title, categories, from, to, cc, bcc, subject, text_body, html_body,
23
23
  content_type, merge_context)
24
- response = get('APIEmailService.addEmailTemplate', title, categories, from, to,
24
+ response = xmlrpc('APIEmailService.addEmailTemplate', title, categories, from, to,
25
25
  cc, bcc, subject, text_body, html_body, content_type, merge_context)
26
26
  end
27
27
 
@@ -45,7 +45,7 @@ module Infusionsoft
45
45
  def email_attach(contact_id, from_name, from_address, to_address, cc_addresses,
46
46
  bcc_addresses, content_type, subject, html_body, txt_body,
47
47
  header, receive_date, send_date)
48
- response = get('APIEmailService.attachEmail', contact_id, from_name, from_address,
48
+ response = xmlrpc('APIEmailService.attachEmail', contact_id, from_name, from_address,
49
49
  to_address, cc_addresses, bcc_addresses, content_type, subject,
50
50
  html_body, txt_body, header, receive_date, send_date)
51
51
  end
@@ -55,7 +55,7 @@ module Infusionsoft
55
55
  # @param [String] merge_context could include Contact, ServiceCall, Opportunity, or CreditCard
56
56
  # @return [Array] returns the merge fields for the given context
57
57
  def email_get_available_merge_fields(merge_context)
58
- response = get('APIEmailService.getAvailableMergeFields', merge_context)
58
+ response = xmlrpc('APIEmailService.getAvailableMergeFields', merge_context)
59
59
  end
60
60
 
61
61
  # Retrieves the details for a particular email template.
@@ -63,7 +63,7 @@ module Infusionsoft
63
63
  # @param [Integer] id
64
64
  # @return [Hash] all data for the email template
65
65
  def email_get_template(id)
66
- response = get('APIEmailService.getEmailTemplate', id)
66
+ response = xmlrpc('APIEmailService.getEmailTemplate', id)
67
67
  end
68
68
 
69
69
  # Retrieves the status of the given email address.
@@ -71,7 +71,7 @@ module Infusionsoft
71
71
  # @param [String] email_address
72
72
  # @return [Integer] 0 = opted out, 1 = single opt-in, 2 = double opt-in
73
73
  def email_get_opt_status(email_address)
74
- response = get('APIEmailService.getOptStatus', email_address)
74
+ response = xmlrpc('APIEmailService.getOptStatus', email_address)
75
75
  end
76
76
 
77
77
  # This method opts-in an email address. This method only works the first time
@@ -83,7 +83,7 @@ module Infusionsoft
83
83
  # reason is passed the system will default a reason of "API Opt In"
84
84
  # @return [Boolean]
85
85
  def email_optin(email_address, reason)
86
- response = get('APIEmailService.optIn', email_address, reason)
86
+ response = xmlrpc('APIEmailService.optIn', email_address, reason)
87
87
  end
88
88
 
89
89
  # Opts-out an email address. Note that once an address is opt-out,
@@ -93,7 +93,7 @@ module Infusionsoft
93
93
  # @param [String] reason
94
94
  # @return [Boolean]
95
95
  def email_optout(email_address, reason)
96
- response = get('APIEmailService.optOut', email_address, reason)
96
+ response = xmlrpc('APIEmailService.optOut', email_address, reason)
97
97
  end
98
98
 
99
99
  # This will send an email to a list of contacts, as well as record the email
@@ -111,7 +111,7 @@ module Infusionsoft
111
111
  # @return [Boolean] returns true/false if the email has been sent
112
112
  def email_send(contact_list, from_address, to_address, cc_addresses,
113
113
  bcc_addresses, content_type, subject, html_body, text_body)
114
- response = get('APIEmailService.sendEmail', contact_list, from_address,
114
+ response = xmlrpc('APIEmailService.sendEmail', contact_list, from_address,
115
115
  to_address, cc_addresses, bcc_addresses, content_type, subject,
116
116
  html_body, text_body)
117
117
  end
@@ -121,9 +121,9 @@ module Infusionsoft
121
121
  #
122
122
  # @param [Array<Integer>] contact_list is an array of Contact id numbers you would like to send this email to
123
123
  # @param [String] The Id of the template to send
124
- # @return returns true if the email has been sent, an error will be sent back otherwise.
124
+ # @return returns true if the email has been sent, an error will be sent back otherwise.
125
125
  def email_send_template(contact_list, template_id)
126
- response = get('APIEmailService.sendEmail', contact_list, template_id)
126
+ response = xmlrpc('APIEmailService.sendEmail', contact_list, template_id)
127
127
  end
128
128
 
129
129
 
@@ -144,7 +144,7 @@ module Infusionsoft
144
144
  # @return [Boolean] returns true/false if teamplate was updated successfully
145
145
  def email_update_template(id, title, category, from, to, cc, bcc, subject,
146
146
  text_body, html_body, content_type, merge_context)
147
- response = get('APIEmailService.updateEmailTemplate', id, title, category, from,
147
+ response = xmlrpc('APIEmailService.updateEmailTemplate', id, title, category, from,
148
148
  to, cc, bcc, subject, text_body, html_body, content_type, merge_context)
149
149
  end
150
150
  end
@@ -2,24 +2,24 @@ module Infusionsoft
2
2
  class Client
3
3
  module File
4
4
  def file_upload(contact_id, file_name, encoded_file_base64)
5
- response = get('FileService.uploadFile', contact_id, file_name, encoded_file_base64)
5
+ response = xmlrpc('FileService.uploadFile', contact_id, file_name, encoded_file_base64)
6
6
  end
7
7
 
8
8
  # returns the Base64 encoded file contents
9
9
  def file_get(id)
10
- response = get('FileService.getFile', id)
10
+ response = xmlrpc('FileService.getFile', id)
11
11
  end
12
12
 
13
13
  def file_url(id)
14
- response = get('FileService.getDownloadUrl', id)
14
+ response = xmlrpc('FileService.getDownloadUrl', id)
15
15
  end
16
16
 
17
17
  def file_rename(id, new_name)
18
- response = get('FileService.renameFile', id, new_name)
18
+ response = xmlrpc('FileService.renameFile', id, new_name)
19
19
  end
20
20
 
21
21
  def file_replace(id, encoded_file_base64)
22
- response = get('FileService.replaceFile', id, encoded_file_base64)
22
+ response = xmlrpc('FileService.replaceFile', id, encoded_file_base64)
23
23
  end
24
24
  end
25
25
  end
@@ -4,15 +4,15 @@ module Infusionsoft
4
4
  module Funnel
5
5
 
6
6
  # Achieves a goal, Returns the result of a goal being achieved.
7
- #
7
+ #
8
8
  # @param integration, string, The integration name of the goal. This defaults to the name of the app.
9
9
  # @param call_name, string, The call name of the goal
10
10
  # @param cid, int, The id of the contact you want to add to a sequence.
11
- #
11
+ #
12
12
  def funnel_achieve_goal(integration, call_name, cid)
13
- response = get('FunnelService.achieveGoal', integration, call_name, cid)
13
+ response = xmlrpc('FunnelService.achieveGoal', integration, call_name, cid)
14
14
  end
15
-
15
+
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module Infusionsoft
12
12
  # @return [Integer] returns the invoice id
13
13
  def invoice_create_blank_order(contact_id, description, order_date, lead_affiliate_id,
14
14
  sale_affiliate_id)
15
- response = get('InvoiceService.createBlankOrder', contact_id, description, order_date,
15
+ response = xmlrpc('InvoiceService.createBlankOrder', contact_id, description, order_date,
16
16
  lead_affiliate_id, sale_affiliate_id)
17
17
  end
18
18
 
@@ -29,7 +29,7 @@ module Infusionsoft
29
29
  # @param [String] notes
30
30
  # @return [Boolean] returns true/false if it was added successfully or not
31
31
  def invoice_add_order_item(invoice_id, product_id, type, price, quantity, description, notes)
32
- response = get('InvoiceService.addOrderItem', invoice_id, product_id, type, price,
32
+ response = xmlrpc('InvoiceService.addOrderItem', invoice_id, product_id, type, price,
33
33
  quantity, description, notes)
34
34
  end
35
35
 
@@ -44,7 +44,7 @@ module Infusionsoft
44
44
  # 'Code' => [String], 'RefNum' => [String], 'Message' => [String]}
45
45
  def invoice_charge_invoice(invoice_id, notes, credit_card_id, merchant_account_id,
46
46
  bypass_commissions)
47
- response = get('InvoiceService.chargeInvoice', invoice_id, notes, credit_card_id,
47
+ response = xmlrpc('InvoiceService.chargeInvoice', invoice_id, notes, credit_card_id,
48
48
  merchant_account_id, bypass_commissions)
49
49
  end
50
50
 
@@ -54,7 +54,7 @@ module Infusionsoft
54
54
  # @param [Integer] cprogram_id the id of the subscription being deleted
55
55
  # @return [Boolean]
56
56
  def invoice_delete_subscription(cprogram_id)
57
- response = get('InvoiceService.deleteSubscription', cprogram_id)
57
+ response = xmlrpc('InvoiceService.deleteSubscription', cprogram_id)
58
58
  end
59
59
 
60
60
  # Creates a subscription for a contact. Subscriptions are billing automatically
@@ -75,7 +75,7 @@ module Infusionsoft
75
75
 
76
76
  api_logger.warn "[DEPRECATION WARNING]: The invoice_add_subscription method more fully complies with Infusionsoft's published API documents. User is advised to review Infusionsoft's API and this gem's documentation for changes in parameters."
77
77
 
78
- response = get('InvoiceService.addRecurringOrder', contact_id,
78
+ response = xmlrpc('InvoiceService.addRecurringOrder', contact_id,
79
79
  allow_duplicate, cprogram_id, merchant_account_id, credit_card_id,
80
80
  affiliate_id, days_till_charge)
81
81
  end
@@ -101,7 +101,7 @@ module Infusionsoft
101
101
  qty, price, allow_tax,
102
102
  merchant_account_id, credit_card_id, affiliate_id,
103
103
  days_till_charge)
104
- response = get('InvoiceService.addRecurringOrder', contact_id,
104
+ response = xmlrpc('InvoiceService.addRecurringOrder', contact_id,
105
105
  allow_duplicate, cprogram_id, qty, price, allow_tax, merchant_account_id, credit_card_id,
106
106
  affiliate_id, days_till_charge)
107
107
  end
@@ -120,7 +120,7 @@ module Infusionsoft
120
120
  # @return [Boolean]
121
121
  def invoice_add_recurring_commission_override(recurring_order_id, affiliate_id,
122
122
  amount, payout_type, description)
123
- response = get('InvoiceService.addRecurringCommissionOverride', recurring_order_id,
123
+ response = xmlrpc('InvoiceService.addRecurringCommissionOverride', recurring_order_id,
124
124
  affiliate_id, amount, payout_type, description)
125
125
  end
126
126
 
@@ -134,7 +134,7 @@ module Infusionsoft
134
134
  # @param [Boolean] bypass_commissions
135
135
  # @return [Boolean]
136
136
  def invoice_add_manual_payment(invoice_id, amount, date, type, description, bypass_commissions)
137
- response = get('InvoiceService.addManualPayment', invoice_id, amount, date, type,
137
+ response = xmlrpc('InvoiceService.addManualPayment', invoice_id, amount, date, type,
138
138
  description, bypass_commissions)
139
139
  end
140
140
 
@@ -145,7 +145,7 @@ module Infusionsoft
145
145
  # @param [Integer] recurring_order_id
146
146
  # @return [Integer] returns the id of the invoice that was created
147
147
  def invoice_create_invoice_for_recurring(recurring_order_id)
148
- response = get('InvoiceService.createInvoiceForRecurring', recurring_order_id)
148
+ response = xmlrpc('InvoiceService.createInvoiceForRecurring', recurring_order_id)
149
149
  end
150
150
 
151
151
  # Adds a payment plan to an existing invoice.
@@ -168,7 +168,7 @@ module Infusionsoft
168
168
  merchant_account_id, days_between_retry, max_retry,
169
169
  initial_payment_amount, initial_payment_date, plan_start_date,
170
170
  number_of_payments, days_between_payments)
171
- response = get('InvoiceService.addPaymentPlan', invoice_id, auto_charge,
171
+ response = xmlrpc('InvoiceService.addPaymentPlan', invoice_id, auto_charge,
172
172
  credit_card_id, merchant_account_id, days_between_retry, max_retry,
173
173
  initial_payment_amount, initial_payment_date, plan_start_date, number_of_payments,
174
174
  days_between_payments)
@@ -179,14 +179,14 @@ module Infusionsoft
179
179
  # @param [Integer] invoice_id
180
180
  # @return [Float]
181
181
  def invoice_calculate_amount_owed(invoice_id)
182
- response = get('InvoiceService.calculateAmountOwed', invoice_id)
182
+ response = xmlrpc('InvoiceService.calculateAmountOwed', invoice_id)
183
183
  end
184
184
 
185
185
  # Retrieve all Payment Types currently setup under the Order Settings section of Infusionsoft.
186
186
  #
187
187
  # @return [Array]
188
188
  def invoice_get_all_payment_otpions
189
- response = get('InvoiceService.getAllPaymentOptions')
189
+ response = xmlrpc('InvoiceService.getAllPaymentOptions')
190
190
  end
191
191
 
192
192
  # Retrieves all payments for a given invoice.
@@ -194,7 +194,7 @@ module Infusionsoft
194
194
  # @param [Integer] invoice_id
195
195
  # @return [Array<Hash>] returns an array of payments
196
196
  def invoice_get_payments(invoice_id)
197
- response = get('Invoice.getPayments', invoice_id)
197
+ response = xmlrpc('Invoice.getPayments', invoice_id)
198
198
  end
199
199
 
200
200
  # Locates an existing card in the system for a contact, using the last 4 digits.
@@ -203,7 +203,7 @@ module Infusionsoft
203
203
  # @param [Integer] last_four
204
204
  # @return [Integer] returns the id of the credit card
205
205
  def invoice_locate_existing_card(contact_id, last_four)
206
- response = get('InvoiceService.locateExistingCard', contact_id, last_four)
206
+ response = xmlrpc('InvoiceService.locateExistingCard', contact_id, last_four)
207
207
  end
208
208
 
209
209
  # Calculates tax, and places it onto the given invoice.
@@ -211,7 +211,7 @@ module Infusionsoft
211
211
  # @param [Integer] invoice_id
212
212
  # @return [Boolean]
213
213
  def invoice_recalculate_tax(invoice_id)
214
- response = get('InvoiceService.recalculateTax', invoice_id)
214
+ response = xmlrpc('InvoiceService.recalculateTax', invoice_id)
215
215
  end
216
216
 
217
217
  # This will validate a credit card in the system.
@@ -219,7 +219,7 @@ module Infusionsoft
219
219
  # @param [Integer] credit_card_id if the card is already in the system
220
220
  # @return [Hash] returns a hash { 'Valid' => false, 'Message' => 'Card is expired' }
221
221
  def invoice_validate_card(credit_card_id)
222
- response = get('InvoiceService.validateCreditCard', credit_card_id)
222
+ response = xmlrpc('InvoiceService.validateCreditCard', credit_card_id)
223
223
  end
224
224
 
225
225
  # This will validate a credit card by passing in values of the
@@ -228,14 +228,14 @@ module Infusionsoft
228
228
  # @param [Hash] data
229
229
  # @return [Hash] returns a hash { 'Valid' => false, 'Message' => 'Card is expired' }
230
230
  def invoice_validate_card(data)
231
- response = get('InvoiceService.validateCreditCard', data)
231
+ response = xmlrpc('InvoiceService.validateCreditCard', data)
232
232
  end
233
233
 
234
234
  # Retrieves the shipping options currently setup for the Infusionsoft shopping cart.
235
235
  #
236
236
  # @return [Array]
237
237
  def invoice_get_all_shipping_options
238
- response = get('Invoice.getAllShippingOptions')
238
+ response = xmlrpc('Invoice.getAllShippingOptions')
239
239
  end
240
240
 
241
241
  # Changes the next bill date on a subscription.
@@ -244,7 +244,7 @@ module Infusionsoft
244
244
  # @param [Date] next_bill_date
245
245
  # @return [Boolean]
246
246
  def invoice_update_recurring_next_bill_date(job_recurring_id, next_bill_date)
247
- response = get('InvoiceService.updateJobRecurringNextBillDate', job_recurring_id, next_bill_date)
247
+ response = xmlrpc('InvoiceService.updateJobRecurringNextBillDate', job_recurring_id, next_bill_date)
248
248
  end
249
249
 
250
250
 
@@ -263,7 +263,7 @@ module Infusionsoft
263
263
  # @return [Boolean]
264
264
  def invoice_add_order_commission_override(invoice_id, affiliate_id, product_id, percentage,
265
265
  amount, payout_type, description, date)
266
- response = get('InvoiceService.addOrderCommissionOverride', invoice_id, affiliate_id,
266
+ response = xmlrpc('InvoiceService.addOrderCommissionOverride', invoice_id, affiliate_id,
267
267
  product_id, percentage, amount, payout_type, description, date)
268
268
  end
269
269
 
@@ -281,7 +281,7 @@ module Infusionsoft
281
281
  # should count towards affiliate commissions.)
282
282
 
283
283
  def add_manual_payment(invoice_id, amount, date, payment_type, description, bypass_commission)
284
- response = get('InvoiceService.addManualPayment', invoice_id, amount,
284
+ response = xmlrpc('InvoiceService.addManualPayment', invoice_id, amount,
285
285
  date, payment_type, description, bypass_commission)
286
286
  end
287
287
 
@@ -290,14 +290,14 @@ module Infusionsoft
290
290
  def invoice_add_recurring_order_with_price(contact_id, allow_duplicate, cprogram_id, qty,
291
291
  price, allow_tax, merchant_account_id,
292
292
  credit_card_id, affiliate_id, days_till_charge)
293
- response = get('InvoiceService.addRecurringOrder', contact_id, allow_duplicate,
293
+ response = xmlrpc('InvoiceService.addRecurringOrder', contact_id, allow_duplicate,
294
294
  cprogram_id, qty, price, allow_tax, merchant_account_id, credit_card_id,
295
295
  affiliate_id, days_till_charge)
296
296
  end
297
297
 
298
298
  # Deprecated - returns the invoice id from a one time order.
299
299
  def invoice_get_invoice_id(order_id)
300
- response = get('InvoiceService.getInvoiceId', order_id)
300
+ response = xmlrpc('InvoiceService.getInvoiceId', order_id)
301
301
  end
302
302
  end
303
303
  end
@@ -1,15 +1,15 @@
1
1
  module Infusionsoft
2
2
  class Client
3
- # The SearchService allows you to retrieve the results of saved searches and reports that
4
- # have been saved within Infusionsoft. Saved searches/reports are tied to the User that
5
- # created them. This service also allows you to utilize the quick search function found in
3
+ # The SearchService allows you to retrieve the results of saved searches and reports that
4
+ # have been saved within Infusionsoft. Saved searches/reports are tied to the User that
5
+ # created them. This service also allows you to utilize the quick search function found in
6
6
  # the upper right hand corner of your Infusionsoft application.
7
7
 
8
- # @note In order to retrieve the id number for saved searches you will need to utilize
9
- # the data_query method and query the table called SavedFilter based on the user_id
10
- # you are looking for the saved search Id for. Also note that UserId field on the
11
- # SavedFilter table can contain multiple userId’s separated by a comma, so if you are
12
- # querying for a report created by userId 6, I recommend appending the wildcard to the
8
+ # @note In order to retrieve the id number for saved searches you will need to utilize
9
+ # the data_query method and query the table called SavedFilter based on the user_id
10
+ # you are looking for the saved search Id for. Also note that UserId field on the
11
+ # SavedFilter table can contain multiple userId’s separated by a comma, so if you are
12
+ # querying for a report created by userId 6, I recommend appending the wildcard to the
13
13
  # end of the userId. Something like $query = array( ‘UserId’ => ’6%’ );
14
14
  module Search
15
15
  # Gets all possible fields/columns available for return on a saved search/report.
@@ -18,7 +18,7 @@ module Infusionsoft
18
18
  # @param [Integer] user_id the user id who the saved search is assigned to
19
19
  # @return [Hash]
20
20
  def search_get_all_report_columns(saved_search_id, user_id)
21
- response = get('SearchService.getAllReportColumns', saved_search_id, user_id)
21
+ response = xmlrpc('SearchService.getAllReportColumns', saved_search_id, user_id)
22
22
  end
23
23
 
24
24
  # Runs a saved search/report and returns all possible fields.
@@ -28,19 +28,19 @@ module Infusionsoft
28
28
  # @param [Integer] page_number
29
29
  # @return [Hash]
30
30
  def search_get_saved_search_results(saved_search_id, user_id, page_number)
31
- response = get('SearchService.getSavedSearchResultsAllFields', saved_search_id,
31
+ response = xmlrpc('SearchService.getSavedSearchResultsAllFields', saved_search_id,
32
32
  user_id, page_number)
33
33
  end
34
34
 
35
35
  # This is used to find what possible quick searches the given user has access to.
36
36
  #
37
37
  # @param [Integer] user_id
38
- # @return [Array]
38
+ # @return [Array]
39
39
  def search_get_available_quick_searches(user_id)
40
- response = get('SearchService.getAvailableQuickSearches', user_id)
40
+ response = xmlrpc('SearchService.getAvailableQuickSearches', user_id)
41
41
  end
42
42
 
43
- # This allows you to run a quick search via the API. The quick search is the
43
+ # This allows you to run a quick search via the API. The quick search is the
44
44
  # search bar in the upper right hand corner of the Infusionsoft application
45
45
  #
46
46
  # @param [String] search_type the type of search (Person, Order, Opportunity, Company, Task,
@@ -51,7 +51,7 @@ module Infusionsoft
51
51
  # @param [Integer] limit max is 1000
52
52
  # @return [Array<Hash>]
53
53
  def search_quick_search(search_type, user_id, search_data, page, limit)
54
- response = get('SearchService.quickSearch', search_type, user_id, search_data, page, limit)
54
+ response = xmlrpc('SearchService.quickSearch', search_type, user_id, search_data, page, limit)
55
55
  end
56
56
 
57
57
  # Retrieves the quick search type that the given users has set as their default.
@@ -59,7 +59,7 @@ module Infusionsoft
59
59
  # @param [Integer] user_id
60
60
  # @return [String] the quick search type that the given user selected as their default
61
61
  def search_get_default_search_type(user_id)
62
- response = get('SearchService.getDefaultQuickSearch', user_id)
62
+ response = xmlrpc('SearchService.getDefaultQuickSearch', user_id)
63
63
  end
64
64
  end
65
65
  end
@@ -2,15 +2,15 @@ module Infusionsoft
2
2
  class Client
3
3
  module Ticket
4
4
  # add move notes to existing tickets
5
- def ticket_add_move_notes(ticket_list, move_notes,
5
+ def ticket_add_move_notes(ticket_list, move_notes,
6
6
  move_to_stage_id, notify_ids)
7
- response = get('ServiceCallService.addMoveNotes', ticket_list,
7
+ response = xmlrpc('ServiceCallService.addMoveNotes', ticket_list,
8
8
  move_notes, move_to_stage_id, notify_ids)
9
9
  end
10
10
 
11
11
  # add move notes to existing tickets
12
12
  def ticket_move_stage(ticket_id, ticket_stage, move_notes, notify_ids)
13
- response = get('ServiceCallService.moveTicketStage',
13
+ response = xmlrpc('ServiceCallService.moveTicketStage',
14
14
  ticket_id, ticket_stage, move_notes, notify_ids)
15
15
  end
16
16
  end
@@ -1,34 +1,58 @@
1
+ require 'rest-client'
2
+
1
3
  module Infusionsoft
2
4
  # Incase Infusionsoft ever creates a restful API :)
3
5
  module Request
6
+ def xmlrpc(service_call, *args)
7
+ connection(service_call, *args)
8
+ end
9
+
4
10
  # Perform an GET request
5
- def get(service_call, *args)
6
- request(:get, service_call, *args)
11
+ def get(path, token, query: {})
12
+ request(:get, path, token, query: query )
7
13
  end
8
14
 
9
- def post(path, params={}, options={})
10
- request(:post, path, params, options)
15
+ def post(path, token, query: {}, payload: {})
16
+ request(:post, path, token, query, payload)
11
17
  end
12
18
 
13
19
  # Perform an HTTP PUT request
14
- def put(path, params={}, options={})
15
- request(:put, path, params, options)
20
+ def put(path, token, query: {}, payload: {})
21
+ request(:put, path, token, query, payload)
16
22
  end
17
23
 
18
- # Perform an HTTP DELETE request
19
- def delete(path, params={}, options={})
20
- request(:delete, path, params, options)
24
+ # Perform an HTTP PATCH request
25
+ def patch(path, token, query: {}, payload: {})
26
+ request(:patch, path, token, query, payload)
21
27
  end
22
28
 
29
+ # Perform an HTTP DELETE request
30
+ def delete(path, token, query: {})
31
+ request(:delete, path, token, query)
32
+ end
23
33
 
24
34
  private
25
35
 
26
36
  # Perform request
27
- def request(method, service_call, *args)
28
- case method.to_sym
29
- when :get
30
- response = connection(service_call, *args)
31
- end
37
+ def request(method, path, token, query={}, payload={})
38
+ path = "/#{path}" unless path.start_with?('/')
39
+ header = {
40
+ authorization: "Bearer #{token.access_token}",
41
+ content_type: :json,
42
+ accept: :json,
43
+ params: query
44
+ }
45
+ opts = {
46
+ method: method,
47
+ url: "https://api.infusionsoft.com/crm/rest/v1" + path,
48
+ headers: header
49
+ }
50
+ opts.merge!( { payload: payload.to_json }) unless payload.empty?
51
+ resp = RestClient::Request.execute(opts)
52
+ rescue RestClient::ExceptionWithResponse => err
53
+ # log error?
54
+ else
55
+ return JSON.parse(resp.body) if resp.body # Some calls respond w nothing
32
56
  end
33
57
  end
34
58
  end
@@ -0,0 +1,77 @@
1
+ require 'rest-client'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module Infusionsoft
6
+ module Rest
7
+
8
+ class Token
9
+ attr_accessor :access_token, :refresh_token, :expiration
10
+
11
+ def initialize(token_params)
12
+ @access_token = token_params[:access_token] || token_params["access_token"]
13
+ @refresh_token = token_params[:refresh_token] || token_params["refresh_token"]
14
+ @expiration = token_params[:expiration] if token_params[:expiration]
15
+
16
+ if token_params[:expires_in] || token_params["expires_in"]
17
+ @expiration = Time.now + (token_params[:expires_in] || token_params["expires_in"])
18
+ end
19
+ end
20
+
21
+ def valid?
22
+ Time.now < expiration
23
+ end
24
+
25
+ class << self
26
+ def auth_url(client_id, redirect_uri)
27
+ params = {
28
+ client_id: client_id,
29
+ redirect_uri: redirect_uri,
30
+ scope: 'full',
31
+ response_type: 'code'
32
+ }
33
+
34
+ uri = URI::HTTPS.build({host: "signin.infusionsoft.com", path: "/app/oauth/authorize", query: URI.encode_www_form(params)})
35
+ uri.to_s
36
+ end
37
+
38
+ def refresh(client_id, client_secret, refresh_token)
39
+ params = {
40
+ grant_type: 'refresh_token',
41
+ refresh_token: refresh_token,
42
+ }
43
+
44
+ header = { "Authorization": "Basic " + Base64.urlsafe_encode64("#{client_id}:#{client_secret}")}
45
+
46
+ response = RestClient.post("https://api.infusionsoft.com/token", params, header)
47
+
48
+ rescue RestClient::ExceptionWithResponse => e
49
+ #TODO what to do here?
50
+ false
51
+ else
52
+ token_params = JSON.parse(response.body)
53
+ self.new(token_params)
54
+ end
55
+
56
+ def get_token(client_id, client_secret, redirect_uri, code)
57
+ params = {
58
+ client_id: client_id,
59
+ client_secret: client_secret,
60
+ redirect_uri: redirect_uri,
61
+ code: code,
62
+ grant_type: 'authorization_code',
63
+ }
64
+
65
+ response = RestClient.post("https://api.infusionsoft.com/token", params)
66
+ rescue RestClient::ExceptionWithResponse => e
67
+ # TODO: what to do here
68
+ false
69
+ else
70
+ token_params = JSON.parse(response.body)
71
+ self.new(token_params)
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+ end
@@ -1,4 +1,4 @@
1
1
  module Infusionsoft
2
2
  # The version of the gem
3
- VERSION = '1.3.0a'.freeze unless defined?(::Infusionsoft::VERSION)
3
+ VERSION = '1.3.5'.freeze unless defined?(::Infusionsoft::VERSION)
4
4
  end
@@ -24,7 +24,6 @@ class ContactTest < Test::Unit::TestCase
24
24
  existing_contact = Infusionsoft.contact_load(3606, [:Id, :FirstName, :LastName, :Email, :Company])
25
25
  result = Infusionsoft.contact_add_with_dup_check(data_hash, 'EmailAndName')
26
26
  assert_equal result, existing_contact['Id']
27
- assert_equal Infusionsoft.contact_load(existing_contact['Id'], [:Company])['Company'], data_hash[:Company]
28
27
  end
29
28
  end
30
29
 
@@ -2,10 +2,10 @@ require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
4
  require 'simplecov'
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
6
6
  SimpleCov::Formatter::HTMLFormatter,
7
7
  Coveralls::SimpleCov::Formatter
8
- ]
8
+ ])
9
9
  SimpleCov.start do
10
10
  add_filter '/vendor/'
11
11
  add_filter '/.bundle/'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infusionsoft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0a
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Leavitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: xmlrpc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: A Ruby wrapper written for the Infusionsoft API
28
56
  email:
29
57
  - nateleavitt@gmail.com
@@ -58,6 +86,7 @@ files:
58
86
  - lib/infusionsoft/exception_handler.rb
59
87
  - lib/infusionsoft/exceptions.rb
60
88
  - lib/infusionsoft/request.rb
89
+ - lib/infusionsoft/rest/token.rb
61
90
  - lib/infusionsoft/version.rb
62
91
  - test/client/contact_test.rb
63
92
  - test/client/data_test.rb
@@ -113,11 +142,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
142
  version: '0'
114
143
  required_rubygems_version: !ruby/object:Gem::Requirement
115
144
  requirements:
116
- - - ">"
145
+ - - ">="
117
146
  - !ruby/object:Gem::Version
118
- version: 1.3.1
147
+ version: 1.3.6
119
148
  requirements: []
120
- rubygems_version: 3.0.1
149
+ rubygems_version: 3.1.2
121
150
  signing_key:
122
151
  specification_version: 4
123
152
  summary: Ruby wrapper for the Infusionsoft API