infusionsoft 1.2.2 → 1.3a

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: e08213b32115b0300bc05722840975c90683fc889df4e86a8729a578ef831da2
4
- data.tar.gz: 18ae1b373d916802649d9e09538c4a03e2d78d43ef182715c86d120ccdf6f658
3
+ metadata.gz: 2867b1878e690ce5af7cd55b395255d33ea30b2968d3772e6437d9dbba8ce4a8
4
+ data.tar.gz: 3a6374077530a73000b9412416171aec72b6033bb44d0aad77d8b19184bb0439
5
5
  SHA512:
6
- metadata.gz: 4e1474eeb747ab8b38fae89adee6811a960f18ec8c2bb191efb61fdb07215cfe572fa7bcd700fe6e2dec7b1141b36ac61309650cacc2926a937332ccd48f7cb4
7
- data.tar.gz: f294a5e219fb5de05f98e737c5b0e96d7867d675f2c79b4939a7879036236f087a253d35e477e172a63155643f938145b338dd5a546f68c03095ff67bd48f10a
6
+ metadata.gz: fa5decfc411f475be47499afa61be77393427812395c9373745e25ac3befee8a1259b6e7623a248b6493a6571962b912838224854ee6ceba7b7e1e7cb772556f
7
+ data.tar.gz: 177bb0b91f4a682e21566761eec97667b6292e2a406ec8d70dfe57bed9a08d98a7828bc7e09311746c735bea969212247462c7cf903803ea05f01d8637859a31
data/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
  A Ruby wrapper for the Infusionsoft API
7
7
 
8
8
  **update notes**
9
+ * upcoming - Adding support for rest api
10
+ * v1.2.2 - Catching Infusionsoft API SSL handshake issues
9
11
  * v1.2.1 - Added OAuth support
10
12
  * v1.2.0 - Added `invoice_add_subscription` call to mirror Infusionsoft API parameters to eventually replace `invoice_add_recurring_order`
11
13
  * maybe?? - Going to add Infusionsoft API authentication Oauth flow. Also, I'm thinking of rewriting parts of it to make the calls more user friendly and adding some convenience methods. If you have any suggestions, let me know.
@@ -22,7 +24,7 @@ A Ruby wrapper for the Infusionsoft API
22
24
 
23
25
  ## <a name="setup">Setup & Configuration</a>
24
26
  1. **Rails 2.3** - add `config.gem 'infusionsoft'` **Rails >= 3** - add `'infusionsoft'` to your `Gemfile`
25
- 2. Enable the API on your Infusionsoft account (if you haven't already) and generate your API Key: [See Infusionsoft Doc](http://ug.infusionsoft.com/article/AA-00442/0/How-do-I-enable-the-Infusionsoft-API-and-generate-an-API-Key.html)
27
+ 2. Enable the API on your Infusionsoft account (if you haven't already) and generate your API Key: [See Infusionsoft Doc](https://classic-infusionsoft.knowledgeowl.com/help/api-key)
26
28
  3. Then create an initializer in `config\initializers` called infusionsoft.rb and the following
27
29
 
28
30
  ```ruby
data/infusionsoft.gemspec CHANGED
@@ -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
 
data/lib/infusionsoft.rb CHANGED
@@ -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
@@ -10,17 +10,17 @@ module Infusionsoft
10
10
  # @example
11
11
  # { :Email => 'test@test.com', :FirstName => 'first_name', :LastName => 'last_name' }
12
12
  def contact_add(data)
13
- contact_id = get('ContactService.add', data)
13
+ contact_id = xmlrpc('ContactService.add', data)
14
14
  if data.has_key?(:Email); email_optin(data[:Email], "requested information"); end
15
15
  return contact_id
16
16
  end
17
-
17
+
18
18
  # Merge two contacts together.
19
19
  #
20
20
  # @param [Integer] contact_id
21
21
  # @param [Integer] duplicate_contact_id
22
22
  def contact_merge(contact_id, duplicate_contact_id)
23
- response = get('ContactService.merge', contact_id, duplicate_contact_id)
23
+ response = xmlrpc('ContactService.merge', contact_id, duplicate_contact_id)
24
24
  end
25
25
 
26
26
  # Adds or updates a contact record based on matching data
@@ -30,7 +30,7 @@ module Infusionsoft
30
30
  # 'EmailAndNameAndCompany'
31
31
  # @return [Integer] id of the contact added or updated
32
32
  def contact_add_with_dup_check(data, check_type)
33
- contact_id = get('ContactService.addWithDupCheck', data, check_type)
33
+ contact_id = xmlrpc('ContactService.addWithDupCheck', data, check_type)
34
34
  if data.has_key?(:Email); email_optin(data[:Email], "requested information"); end
35
35
  return contact_id
36
36
  end
@@ -43,7 +43,7 @@ module Infusionsoft
43
43
  # @example
44
44
  # { :FirstName => 'first_name', :StreetAddress1 => '123 N Street' }
45
45
  def contact_update(contact_id, data)
46
- contact_id = get('ContactService.update', contact_id, data)
46
+ contact_id = xmlrpc('ContactService.update', contact_id, data)
47
47
  if data.has_key?(:Email); email_optin(data[:Email], "requested information"); end
48
48
  return contact_id
49
49
  end
@@ -56,7 +56,7 @@ module Infusionsoft
56
56
  # @example this is what you would get back
57
57
  # { "FirstName" => "John", "LastName" => "Doe" }
58
58
  def contact_load(id, selected_fields)
59
- response = get('ContactService.load', id, selected_fields)
59
+ response = xmlrpc('ContactService.load', id, selected_fields)
60
60
  end
61
61
 
62
62
  # Finds all contacts with the supplied email address in any of the three contact record email
@@ -66,7 +66,7 @@ module Infusionsoft
66
66
  # @param [Array] selected_fields the list of fields you want with it's data
67
67
  # @return [Array<Hash>] the list of contacts with it's fields and data
68
68
  def contact_find_by_email(email, selected_fields)
69
- response = get('ContactService.findByEmail', email, selected_fields)
69
+ response = xmlrpc('ContactService.findByEmail', email, selected_fields)
70
70
  end
71
71
 
72
72
  # Adds a contact to a follow-up sequence (campaigns were the original name of follow-up sequences).
@@ -76,7 +76,7 @@ module Infusionsoft
76
76
  # @return [Boolean] returns true/false if the contact was added to the follow-up sequence
77
77
  # successfully
78
78
  def contact_add_to_campaign(contact_id, campaign_id)
79
- response = get('ContactService.addToCampaign', contact_id, campaign_id)
79
+ response = xmlrpc('ContactService.addToCampaign', contact_id, campaign_id)
80
80
  end
81
81
 
82
82
  # Returns the Id number of the next follow-up sequence step for the given contact.
@@ -86,7 +86,7 @@ module Infusionsoft
86
86
  # @return [Integer] id number of the next unfishished step in the given follow up sequence
87
87
  # for the given contact
88
88
  def contact_get_next_campaign_step(contact_id, campaign_id)
89
- response = get('ContactService.getNextCampaignStep', contact_id, campaign_id)
89
+ response = xmlrpc('ContactService.getNextCampaignStep', contact_id, campaign_id)
90
90
  end
91
91
 
92
92
  # Pauses a follow-up sequence for the given contact record
@@ -95,7 +95,7 @@ module Infusionsoft
95
95
  # @param [Integer] campaign_id
96
96
  # @return [Boolean] returns true/false if the sequence was paused
97
97
  def contact_pause_campaign(contact_id, campaign_id)
98
- response = get('ContactService.pauseCampaign', contact_id, campaign_id)
98
+ response = xmlrpc('ContactService.pauseCampaign', contact_id, campaign_id)
99
99
  end
100
100
 
101
101
  # Removes a follow-up sequence from a contact record
@@ -104,7 +104,7 @@ module Infusionsoft
104
104
  # @param [Integer] campaign_id
105
105
  # @return [Boolean] returns true/false if removed
106
106
  def contact_remove_from_campaign(contact_id, campaign_id)
107
- response = get('ContactService.removeFromCampaign', contact_id, campaign_id)
107
+ response = xmlrpc('ContactService.removeFromCampaign', contact_id, campaign_id)
108
108
  end
109
109
 
110
110
  # Resumes a follow-up sequence that has been stopped/paused for a given contact.
@@ -113,7 +113,7 @@ module Infusionsoft
113
113
  # @param [Ingeger] campaign_id
114
114
  # @return [Boolean] returns true/false if sequence was resumed
115
115
  def contact_resume_campaign(contact_id, campaign_id)
116
- response = get('ConactService.resumeCampaignForContact', contact_id, campaign_id)
116
+ response = xmlrpc('ConactService.resumeCampaignForContact', contact_id, campaign_id)
117
117
  end
118
118
 
119
119
  # Immediately performs the given follow-up sequence step_id for the given contacts.
@@ -122,7 +122,7 @@ module Infusionsoft
122
122
  # @param [Integer] ) step_id
123
123
  # @return [Boolean] returns true/false if the step was rescheduled
124
124
  def contact_reschedule_campaign_step(list_of_contacts, step_id)
125
- response = get('ContactService.reschedulteCampaignStep', list_of_contacts, step_id)
125
+ response = xmlrpc('ContactService.reschedulteCampaignStep', list_of_contacts, step_id)
126
126
  end
127
127
 
128
128
  # Removes a tag from a contact (groups were the original name of tags).
@@ -131,7 +131,7 @@ module Infusionsoft
131
131
  # @param [Integer] group_id
132
132
  # @return [Boolean] returns true/false if tag was removed successfully
133
133
  def contact_remove_from_group(contact_id, group_id)
134
- response = get('ContactService.removeFromGroup', contact_id, group_id)
134
+ response = xmlrpc('ContactService.removeFromGroup', contact_id, group_id)
135
135
  end
136
136
 
137
137
  # Adds a tag to a contact
@@ -140,7 +140,7 @@ module Infusionsoft
140
140
  # @param [Integer] group_id
141
141
  # @return [Boolean] returns true/false if the tag was added successfully
142
142
  def contact_add_to_group(contact_id, group_id)
143
- response = get('ContactService.addToGroup', contact_id, group_id)
143
+ response = xmlrpc('ContactService.addToGroup', contact_id, group_id)
144
144
  end
145
145
 
146
146
  # Runs an action set on a given contact record
@@ -152,20 +152,20 @@ module Infusionsoft
152
152
  # [{ 'Action' => 'Create Task', 'Message' => 'task1 (Task) sent successfully', 'isError' =>
153
153
  # nil }]
154
154
  def contact_run_action_set(contact_id, action_set_id)
155
- response = get('ContactService.runActionSequence', contact_id, action_set_id)
155
+ response = xmlrpc('ContactService.runActionSequence', contact_id, action_set_id)
156
156
  end
157
157
 
158
158
  def contact_link_contact(remoteApp, remoteId, localId)
159
- response = get('ContactService.linkContact', remoteApp, remoteId, localId)
159
+ response = xmlrpc('ContactService.linkContact', remoteApp, remoteId, localId)
160
160
  end
161
161
 
162
162
 
163
163
  def contact_locate_contact_link(locate_map_id)
164
- response = get('ContactService.locateContactLink', locate_map_id)
164
+ response = xmlrpc('ContactService.locateContactLink', locate_map_id)
165
165
  end
166
166
 
167
167
  def contact_mark_link_updated(locate_map_id)
168
- response = get('ContactService.markLinkUpdated', locate_map_id)
168
+ response = xmlrpc('ContactService.markLinkUpdated', locate_map_id)
169
169
  end
170
170
 
171
171
  # Creates a new recurring order for a contact.
@@ -178,7 +178,7 @@ module Infusionsoft
178
178
  # @param [Integer] affiliate_id
179
179
  def contact_add_recurring_order(contact_id, allow_duplicate, cprogram_id, merchant_account_id,
180
180
  credit_card_id, affiliate_id, days_till_charge)
181
- response = get('ContactService.addRecurringOrder', contact_id, allow_duplicate, cprogram_id,
181
+ response = xmlrpc('ContactService.addRecurringOrder', contact_id, allow_duplicate, cprogram_id,
182
182
  merchant_account_id, credit_card_id, affiliate_id, days_till_charge)
183
183
  end
184
184
 
@@ -189,7 +189,7 @@ module Infusionsoft
189
189
  # @param [Integer] action_set_id
190
190
  # @param [Hash] data
191
191
  def contact_run_action_set_with_params(contact_id, action_set_id, data)
192
- response = get('ContactService.runActionSequence', contact_id, action_set_id, data)
192
+ response = xmlrpc('ContactService.runActionSequence', contact_id, action_set_id, data)
193
193
  end
194
194
 
195
195
  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,53 @@
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
24
  # Perform an HTTP DELETE request
19
- def delete(path, params={}, options={})
20
- request(:delete, path, params, options)
25
+ def delete(path, token, query: {})
26
+ request(:delete, path, token, query)
21
27
  end
22
28
 
23
-
24
29
  private
25
30
 
26
31
  # 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
32
+ def request(method, path, token, query={}, payload={})
33
+ path = "/#{path}" unless path.start_with?('/')
34
+ header = {
35
+ authorization: "Bearer #{token.access_token}",
36
+ content_type: :json,
37
+ accept: :json,
38
+ params: query
39
+ }
40
+ opts = {
41
+ method: method,
42
+ url: "https://api.infusionsoft.com/crm/rest/v1" + path,
43
+ headers: header
44
+ }
45
+ opts.merge!( { payload: payload.to_json }) unless payload.empty?
46
+ resp = RestClient::Request.execute(opts)
47
+ rescue RestClient::ExceptionWithResponse => err
48
+ # log error?
49
+ else
50
+ return JSON.parse(resp.body)
32
51
  end
33
52
  end
34
53
  end
@@ -0,0 +1,73 @@
1
+ require 'rest-client'
2
+ require 'uri'
3
+ module Infusionsoft
4
+ module Rest
5
+
6
+ class Token
7
+ attr_accessor :access_token, :refresh_token, :expiration
8
+
9
+ def initialize(token_params)
10
+ access_token = token_params[:access_token]
11
+ refresh_token = token_params[:refresh_token]
12
+ expiration = token_params[:expiration] if token_params[:expiration]
13
+
14
+ if token_params[:expires_in]
15
+ expiration = Time.now + token_params[:expires_in]
16
+ end
17
+ end
18
+
19
+ def valid?
20
+ Time.now < expiration
21
+ end
22
+
23
+ class << self
24
+ def auth_url(client_id, redirect_uri)
25
+ params = {
26
+ client_id: client_id,
27
+ redirect_uri: redirect_uri,
28
+ scope: 'full',
29
+ response_type: 'code'
30
+ }
31
+
32
+ uri = URI::HTTPS.build({host: "signin.infusionsoft.com", path: "/app/oauth/authorize", query: URI.encode_www_form(params)})
33
+ uri.to_s
34
+ end
35
+
36
+ def refresh(client_id, client_secret, refresh_token)
37
+ params = {
38
+ grant_type: 'refresh_token',
39
+ refresh_token: refresh_token,
40
+ }
41
+
42
+ header = { "Authorization": "Basic " + Base64.urlsafe_encode64("#{client_id}:#{client_secret}")}
43
+
44
+ response = RestClient.post("https://api.infusionsoft.com/token", params, header)
45
+
46
+ rescue RestClient::ExceptionWithRespone => e
47
+ #TODO what to do here?
48
+ else
49
+ token_params = JSON.parse(response.body).symbolize_keys
50
+ self.new(token_params)
51
+ end
52
+
53
+ def get_token(client_id, client_secret, redirect_uri, code)
54
+ params = {
55
+ client_id: client_id,
56
+ client_secret: client_secret,
57
+ redirect_uri: redirect_uri,
58
+ code: code,
59
+ grant_type: 'authorization_code',
60
+ }
61
+
62
+ response = RestClient.post("https://api.infusionsoft.com/token", params)
63
+ rescue RestClient::ExceptionWithResponse => e
64
+ # TODO: what to do here
65
+ else
66
+ token_params = JSON.parse(response.body).symbolize_keys
67
+ self.new(token_params)
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ end
@@ -1,4 +1,4 @@
1
1
  module Infusionsoft
2
2
  # The version of the gem
3
- VERSION = '1.2.2'.freeze unless defined?(::Infusionsoft::VERSION)
3
+ VERSION = '1.3a'.freeze unless defined?(::Infusionsoft::VERSION)
4
4
  end
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.2.2
4
+ version: 1.3a
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Leavitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2019-01-10 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,9 +142,9 @@ 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.6
147
+ version: 1.3.1
119
148
  requirements: []
120
149
  rubyforge_project:
121
150
  rubygems_version: 2.7.6