infusion-api 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmJlYmM2OTg1YTlmNDViNGNiZDc2YjdhMTg3YWRmYzgwYzRkZjYzZA==
4
+ Mjc3MTM4Y2M4NWJhZWM0MWRlYjI4YjY2YjMwMTFlNGE3MzcwMDVlNg==
5
5
  data.tar.gz: !binary |-
6
- NjkxMWY5OWIxMGU2ZmQ5OGM5NWFjNzVjMThjNmEyZmNiMWQ2NzlhYQ==
6
+ ZTJkMzIwMjUyMTU5YmRjOTE1ZTJlMTM5Y2JlZjgyNmFmYzYwOTZhYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjMxNzg2YmU3OWNiMmEwY2NmZjFmNjkzNTBiNTc2ZDRkOGJjNTFmMjhlNjQ4
10
- OGZmODc1NmQ1MGY0NWNlMmQ5MjI4ZjdjYjEzZmNhY2E5MDhiM2M3YWFhNzli
11
- NGM3ZTIwMTI3Yzk0ODQ0YjEyOWI2MTA4YjE4MTk4NjM1Y2UxMjk=
9
+ ZTk1ZjQ4MjI4Y2Y2MTQwMDY0MDBjOGZmODA2ZDE0ZDQ0MjM3NzFhZjZiYjA1
10
+ OGQzNGI5NWRlZmEzMDI4YTVjMjc0YTcwYWE5NDBhMzlmZTRmOTBhY2Y3NWNi
11
+ YTBjMjk4NzQ1MWM5NDg3YWE1M2FjNTYyOTJiOTAxYTdmYmUyZjI=
12
12
  data.tar.gz: !binary |-
13
- Y2EyNjYxZjhiOTIzNjE2YzdkYzQwY2VjNGYxMzNmNTM2N2ZjMWI0MzZlZTdm
14
- MGQzM2M1MDhjNDM3NTNkMmJhNWQwMzE3M2M2ZTc1MTZmYTllYzFlZTk0YTA2
15
- ZmM3MzdhYzZiMGNlNzdkY2QzNzgwN2M5OWQ1ZDE0ZmQxMmM2ODM=
13
+ ZjU3YjczN2U2MDNhMzNhOThhNmYxMjNjZWI0MWU2YjI0M2M5ZDU1MDUwNDBi
14
+ YTRkMzMzNjRlMTI2MzFiODVmNjliOTYwZWExMTVkNDVhYmQ5ODAxZTE1YmY1
15
+ Mzc3M2YxYmJjMTMwZDRjYTAxNzE0ZDAxYjIwYTNiMTZlOTJkMmI=
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ log/*.log
3
+ tmp/**/*
4
+ .DS_Store
5
+ rdoc/
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011 Nathan Leavitt & Infused Systems
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # The Infusionsoft Ruby Gem
2
+ A Ruby wrapper for the Infusionsoft API
3
+
4
+ **This is a complete rewrite and has been implemented as a RubyGem**
5
+ All previous versions will need to update their calls to follow the new schema
6
+
7
+ ## <a name="installation">Installation</a>
8
+ gem install infusionsoft
9
+
10
+ ## <a name="documentation">Documentation</a>
11
+ [http://rubydoc.info/gems/infusionsoft/frames](http://rubydoc.info/gems/infusionsoft/frames)
12
+
13
+ ## <a name="setup">Setup & Configuration</a>
14
+ 1. **Rails 2.3** - add `config.gem 'infusionsoft'` **Rails 3** - add `'infusionsoft'` to your `Gemfile`
15
+ 2. Then create an initializer in `config\initializers` called infusionsoft.rb and the following
16
+
17
+ <b></b>
18
+
19
+ # Added to your config\initializers file
20
+ Infusionsoft.configure do |config|
21
+ config.api_url = 'YOUR_INFUSIONSOFT_URL' # example infused.infusionsoft.com
22
+ config.api_key = 'YOUR_INFUSIONSOFT_API_KEY'
23
+ end
24
+
25
+ ## <a name="examples">Usage Examples</a>
26
+
27
+ # Get a users first and last name using the DataService
28
+ Infusionsoft.data_load('Contact', contact_id, [:FirstName, :LastName])
29
+
30
+ # Update a contact with specific field values
31
+ Infusionsoft.contact_update(contact_id, { :FirstName => 'first_name', :Email => 'test@test.com' })
32
+
33
+ # Add a new Contact
34
+ Infusionsoft.contact_add({:FirstName => 'first_name', :LastName => 'last_name', :Email => 'test@test.com'})
35
+
36
+ # Create a blank Invoice
37
+ invoice_id = Infusionsoft.invoice_create_blank_order(contact_id, description, Date.today, lead_affiliate_id, sale_affiliate_id)
38
+
39
+ # Then add item to invoice
40
+ Infusionsoft.invoice_add_order_item(invoice_id, product_id, product_type, amount, quantity, description_here, notes)
41
+
42
+ # Then charge the invoice
43
+ Infusionsoft.invoice_charge_invoice(invoice_id, notes, credit_card_id, merchange_id, bypass_commissions)
44
+
45
+
46
+ ## <a name="contributing">Contributing</a>
47
+ In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
48
+
49
+ Here are some ways *you* can contribute:
50
+
51
+ * by using alpha, beta, and prerelease versions
52
+ * by reporting bugs
53
+ * by suggesting new features
54
+ * by writing or editing documentation
55
+ * by writing specifications
56
+ * by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
57
+ * by refactoring code
58
+ * by closing [issues](https://github.com/nateleavitt/infusionsoft/issues)
59
+ * by reviewing patches
60
+
61
+ ## <a name="issues">Submitting an Issue</a>
62
+ We use the [GitHub issue tracker](https://github.com/nateleavitt/infusionsoft/issues) to track bugs and
63
+ features. Before submitting a bug report or feature request, check to make sure it hasn't already
64
+ been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
65
+ bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
66
+ details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
67
+ operating system. Ideally, a bug report should include a pull request with failing specs.
68
+
69
+ ## <a name="pulls">Submitting a Pull Request</a>
70
+ 1. Fork the project.
71
+ 2. Create a topic branch.
72
+ 3. Implement your feature or bug fix.
73
+ 4. Add documentation for your feature or bug fix.
74
+ 5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
75
+ 6. Add specs for your feature or bug fix.
76
+ 7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
77
+ 8. Commit and push your changes.
78
+ 9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
79
+
80
+ ## <a name="rubies">Supported Rubies</a>
81
+ This library aims to support the following Ruby implementations:
82
+
83
+ * Ruby 1.8.7
84
+ * Ruby 1.9.1
85
+ * Ruby 1.9.2
86
+ * [JRuby](http://www.jruby.org/)
87
+ * [Rubinius](http://rubini.us/)
88
+ * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
89
+
90
+ If something doesn't work on one of these interpreters, it should be considered
91
+ a bug.
92
+
93
+ This library may inadvertently work (or seem to work) on other Ruby
94
+ implementations, however support will only be provided for the versions listed
95
+ above.
96
+
97
+ If you would like this library to support another Ruby version, you may
98
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
99
+ run and pass on that implementation. When something breaks on your
100
+ implementation, you will be personally responsible for providing patches in a
101
+ timely fashion. If critical issues for a particular implementation exist at the
102
+ time of a major release, support for that Ruby version may be dropped.
103
+
104
+ ## <a name="todos">Todos</a>
105
+ * Need to fully implement testing
106
+ * Need to add a history log for additional contributers
107
+
108
+ ## <a name="copyright">Copyright</a>
109
+ Copyright (c) 2012 Nathan Leavitt
110
+ See [LICENSE](https://github.com/nateleavitt/infusionsoft/blob/master/LICENSE.md) for details.
111
+
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/infusion-api/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'infusion-api'
6
+ gem.summary = %q{Ruby wrapper for the Infusionsoft API - Forked from Nathan Leavitt}
7
+ gem.description = 'A Ruby wrapper written for the Infusionsoft API. Forked from Nathan Leavitt'
8
+ gem.authors = ["Updated by Raj Shah"]
9
+ gem.email = ['drrajshah@me.com']
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.homepage = 'http://rubygems.org/gems/infusion-api'
13
+ gem.require_paths = ['lib']
14
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
15
+
16
+ gem.version = Infusionsoft::VERSION.dup
17
+ end
18
+
@@ -0,0 +1,24 @@
1
+ require 'infusion-api/configuration'
2
+ require 'infusion-api/connection'
3
+ require 'infusion-api/request'
4
+
5
+ module Infusionsoft
6
+
7
+ class Api
8
+ include Connection
9
+ include Request
10
+
11
+ attr_accessor :retry_count
12
+ attr_accessor *Configuration::VALID_OPTION_KEYS
13
+
14
+ def initialize(options={})
15
+ @retry_count = 0
16
+ options = Infusionsoft.options.merge(options)
17
+ Configuration::VALID_OPTION_KEYS.each do |key|
18
+ send("#{key}=", options[key])
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,62 @@
1
+ module Infusionsoft
2
+ class Client
3
+ # The Affiliate service is used to pull commission data and activities for affiliates.
4
+ # With this service, you have access to Clawbacks, Commissions, Payouts, Running Totals,
5
+ # and the Activity Summary. The methods in the Affiliate service mirror the reports
6
+ # produced inside Infusionsoft.
7
+ #
8
+ # @note To manage affiliate information (ie Name, Phone, etc.) you will need to use the Data service.
9
+ module Affiliate
10
+ # Used when you need to retrieve all clawed back commissions for a particular affiliate.
11
+ #
12
+ # @param [Integer] affiliate_id
13
+ # @params [Date] start_date
14
+ # @end_date [Date] end_date
15
+ # @return [Array] all claw backs for the given affiliate that have occurred within the date
16
+ # range specified
17
+ def affiliate_clawbacks(affiliate_id, start_date, end_date)
18
+ response = get('APIAffiliateService.affClawbacks', affiliate_id, start_date, end_date)
19
+ end
20
+
21
+ # Used to retrieve all commissions for a specific affiliate within a date range.
22
+ #
23
+ # @param [Integer] affiliate_id
24
+ # @param [Date] start_date
25
+ # @param [Date] end_date
26
+ # @return [Array] all sales commissions for the given affiliate earned within the date range
27
+ # specified
28
+ def affiliate_commissions(affiliate_id, start_date, end_date)
29
+ response = get('APIAffiliateService.affCommissions', affiliate_id, start_date, end_date)
30
+ end
31
+
32
+ # Used to retrieve all payments for a specific affiliate within a date range.
33
+ #
34
+ # @param [Integer] affiliate_id
35
+ # @param [Date] start_date
36
+ # @param [Date] end_date
37
+ # @return [Array] a list of rows, each row is a single payout
38
+ def affiliate_payouts(affiliate_id, start_date, end_date)
39
+ response = get('APIAffiliateService.affPayouts', affiliate_id, start_date, end_date)
40
+ end
41
+
42
+ # This method is used to retrieve all commissions for a specific affiliate within a date range.
43
+ #
44
+ # @param [Array] affiliate_list
45
+ # @return [Array] all sales commissions for the given affiliate earned within the date range
46
+ # specified
47
+ def affiliate_running_totals(affiliate_list)
48
+ response = get('APIAffiliateService.affRunningTotals', affiliate_list)
49
+ end
50
+
51
+ # Used to retrieve a summary of statistics for a list of affiliates.
52
+ #
53
+ # @param [Array] affiliate_list
54
+ # @param [Date] start_date
55
+ # @param [Date] end_date
56
+ # @return [Array<Hash>] a summary of the affiliates information for a specified date range
57
+ def affiliate_summary(affiliate_list, start_date, end_date)
58
+ response = get('APIAffiliateService.affSummary', affiliate_list, start_date, end_date)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,187 @@
1
+ module Infusionsoft
2
+ class Client
3
+ # Contact service is used to manage contacts. You can add, update and find contacts in
4
+ # addition to managing follow up sequences, tags and action sets.
5
+ module Contact
6
+ # Creates a new contact record from the data passed in the associative array.
7
+ #
8
+ # @param [Hash] data contains the mappable contact fields and it's data
9
+ # @return [Integer] the id of the newly added contact
10
+ # @example
11
+ # { :Email => 'test@test.com', :FirstName => 'first_name', :LastName => 'last_name' }
12
+ def contact_add(data)
13
+ contact_id = get('ContactService.add', data)
14
+ if data.has_key?("Email"); email_optin(data["Email"], "requested information"); end
15
+ return contact_id
16
+ end
17
+
18
+ # Adds or updates a contact record based on matching data
19
+ #
20
+ # @param [Array<Hash>] data the contact data you want added
21
+ # @param [String] check_type available options are 'Email', 'EmailAndName',
22
+ # 'EmailAndNameAndCompany'
23
+ # @return [Integer] id of the contact added or updated
24
+ def contact_add_with_dup_check(data, check_type)
25
+ response = get('ContactService.addWithDupCheck', data, check_type)
26
+ end
27
+
28
+ # Updates a contact in the database.
29
+ #
30
+ # @param [Integer] contact_id
31
+ # @param [Hash] data contains the mappable contact fields and it's data
32
+ # @return [Integer] the id of the contact updated
33
+ # @example
34
+ # { :FirstName => 'first_name', :StreetAddress1 => '123 N Street' }
35
+ def contact_update(contact_id, data)
36
+ bool = get('ContactService.update', contact_id, data)
37
+ if data.has_key?("Email"); email_optin(data["Email"], "requested information"); end
38
+ return bool
39
+ end
40
+
41
+ # Loads a contact from the database
42
+ #
43
+ # @param [Integer] id
44
+ # @param [Array] selected_fields the list of fields you want back
45
+ # @return [Array] the fields returned back with it's data
46
+ # @example this is what you would get back
47
+ # { "FirstName" => "John", "LastName" => "Doe" }
48
+ def contact_load(id, selected_fields)
49
+ response = get('ContactService.load', id, selected_fields)
50
+ end
51
+
52
+ # Finds all contacts with the supplied email address in any of the three contact record email
53
+ # addresses.
54
+ #
55
+ # @param [String] email
56
+ # @param [Array] selected_fields the list of fields you want with it's data
57
+ # @return [Array<Hash>] the list of contacts with it's fields and data
58
+ def contact_find_by_email(email, selected_fields)
59
+ response = get('ContactService.findByEmail', email, selected_fields)
60
+ end
61
+
62
+ # Adds a contact to a follow-up sequence (campaigns were the original name of follow-up sequences).
63
+ #
64
+ # @param [Integer] contact_id
65
+ # @param [Integer] campaign_id
66
+ # @return [Boolean] returns true/false if the contact was added to the follow-up sequence
67
+ # successfully
68
+ def contact_add_to_campaign(contact_id, campaign_id)
69
+ response = get('ContactService.addToCampaign', contact_id, campaign_id)
70
+ end
71
+
72
+ # Returns the Id number of the next follow-up sequence step for the given contact.
73
+ #
74
+ # @param [Integer] contact_id
75
+ # @param [Integer] campaign_id
76
+ # @return [Integer] id number of the next unfishished step in the given follow up sequence
77
+ # for the given contact
78
+ def contact_get_next_campaign_step(contact_id, campaign_id)
79
+ response = get('ContactService.getNextCampaignStep', contact_id, campaign_id)
80
+ end
81
+
82
+ # Pauses a follow-up sequence for the given contact record
83
+ #
84
+ # @param [Integer] contact_id
85
+ # @param [Integer] campaign_id
86
+ # @return [Boolean] returns true/false if the sequence was paused
87
+ def contact_pause_campaign(contact_id, campaign_id)
88
+ response = get('ContactService.pauseCampaign', contact_id, campaign_id)
89
+ end
90
+
91
+ # Removes a follow-up sequence from a contact record
92
+ #
93
+ # @param [Integer] contact_id
94
+ # @param [Integer] campaign_id
95
+ # @return [Boolean] returns true/false if removed
96
+ def contact_remove_from_campaign(contact_id, campaign_id)
97
+ response = get('ContactService.removeFromCampaign', contact_id, campaign_id)
98
+ end
99
+
100
+ # Resumes a follow-up sequence that has been stopped/paused for a given contact.
101
+ #
102
+ # @param [Integer] contact_id
103
+ # @param [Ingeger] campaign_id
104
+ # @return [Boolean] returns true/false if sequence was resumed
105
+ def contact_resume_campaign(contact_id, campaign_id)
106
+ response = get('ConactService.resumeCampaignForContact', contact_id, campaign_id)
107
+ end
108
+
109
+ # Immediately performs the given follow-up sequence step_id for the given contacts.
110
+ #
111
+ # @param [Array<Integer>] list_of_contacts
112
+ # @param [Integer] ) step_id
113
+ # @return [Boolean] returns true/false if the step was rescheduled
114
+ def contact_reschedule_campaign_step(list_of_contacts, step_id)
115
+ response = get('ContactService.reschedulteCampaignStep', list_of_contacts, step_id)
116
+ end
117
+
118
+ # Removes a tag from a contact (groups were the original name of tags).
119
+ #
120
+ # @param [Integer] contact_id
121
+ # @param [Integer] group_id
122
+ # @return [Boolean] returns true/false if tag was removed successfully
123
+ def contact_remove_from_group(contact_id, group_id)
124
+ response = get('ContactService.removeFromGroup', contact_id, group_id)
125
+ end
126
+
127
+ # Adds a tag to a contact
128
+ #
129
+ # @param [Integer] contact_id
130
+ # @param [Integer] group_id
131
+ # @return [Boolean] returns true/false if the tag was added successfully
132
+ def contact_add_to_group(contact_id, group_id)
133
+ response = get('ContactService.addToGroup', contact_id, group_id)
134
+ end
135
+
136
+ # Runs an action set on a given contact record
137
+ #
138
+ # @param [Integer] contact_id
139
+ # @param [Integer] action_set_id
140
+ # @return [Array<Hash>] A list of details on each action run
141
+ # @example here is a list of what you get back
142
+ # [{ 'Action' => 'Create Task', 'Message' => 'task1 (Task) sent successfully', 'isError' =>
143
+ # nil }]
144
+ def contact_run_action_set(contact_id, action_set_id)
145
+ response = get('ContactService.runActionSequence', contact_id, action_set_id)
146
+ end
147
+
148
+ def contact_link_contact(remoteApp, remoteId, localId)
149
+ response = get('ContactService.linkContact', remoteApp, remoteId, localId)
150
+ end
151
+
152
+
153
+ def contact_locate_contact_link(locate_map_id)
154
+ response = get('ContactService.locateContactLink', locate_map_id)
155
+ end
156
+
157
+ def contact_mark_link_updated(locate_map_id)
158
+ response = get('ContactService.markLinkUpdated', locate_map_id)
159
+ end
160
+
161
+ # Creates a new recurring order for a contact.
162
+ #
163
+ # @param [Integer] contact_id
164
+ # @param [Boolean] allow_duplicate
165
+ # @param [Integer] cprogram_id
166
+ # @param [Integer] merchant_account_id
167
+ # @param [Integer] credit_card_id
168
+ # @param [Integer] affiliate_id
169
+ def contact_add_recurring_order(contact_id, allow_duplicate, cprogram_id, merchant_account_id,
170
+ credit_card_id, affiliate_id, days_till_charge)
171
+ response = get('ContactService.addRecurringOrder', contact_id, allow_duplicate, cprogram_id,
172
+ merchant_account_id, credit_card_id, affiliate_id, days_till_charge)
173
+ end
174
+
175
+ # Executes an action sequence for a given contact, passing in runtime params
176
+ # for running affiliate signup actions, etc
177
+ #
178
+ # @param [Integer] contact_id
179
+ # @param [Integer] action_set_id
180
+ # @param [Hash] data
181
+ def contact_run_action_set_with_params(contact_id, action_set_id, data)
182
+ response = get('ContactService.runActionSequence', contact_id, action_set_id, data)
183
+ end
184
+
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,24 @@
1
+ module Infusionsoft
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,
5
+ # adding credit cards through the API will no longer be supported.
6
+ module CreditCard
7
+
8
+ # This service will request a token that will be used when submitting
9
+ # a new credit card through a form
10
+ #
11
+ # @param [Integer] contact_id of the Infusionsoft contact
12
+ # @param [String] url that will be redirected to upon successfully adding card
13
+ # @param [String] url that will be redirected to when there is a failure upon adding card
14
+ def credit_card_request_token(contact_id, success_url, failure_url)
15
+ response = get('CreditCardSubmissionService.requestSubmissionToken', contact_id, success_url, failure_url)
16
+ end
17
+
18
+ def credit_card_lookup_by_token(token)
19
+ response = get('CreditCardSubmissionService.requestCreditCardId', token)
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,147 @@
1
+ module Infusionsoft
2
+ class Client
3
+ # The Data service is used to manipulate most data in Infusionsoft. It permits you to
4
+ # work on any available tables and has a wide range of uses.
5
+ module Data
6
+ # Adds a record with the data provided.
7
+ #
8
+ # @param [String] table the name of the Infusiosoft database table
9
+ # @param [Hash] data the fields and it's data
10
+ # @return [Integer] returns the id of the record added
11
+ def data_add(table, data)
12
+ response = get('DataService.add', table, data)
13
+ end
14
+
15
+ # This method will load a record from the database given the primary key.
16
+ #
17
+ # @param [String] table
18
+ # @param [Integer] id
19
+ # @param [Array] selected_fields
20
+ # @return [Hash] the field names and their data
21
+ # @example
22
+ # { "FirstName" => "John", "LastName" => "Doe" }
23
+ def data_load(table, id, selected_fields)
24
+ response = get('DataService.load', table, id, selected_fields)
25
+ end
26
+
27
+ # Updates the specified record (indicated by ID) with the data provided.
28
+ #
29
+ # @param [String] table
30
+ # @param [Integer] id
31
+ # @param [Hash] data this is the fields and values you would like to update
32
+ # @return [Integer] id of the record updated
33
+ # @example
34
+ # { :FirstName => 'John', :Email => 'test@test.com' }
35
+ def data_update(table, id, data)
36
+ response = get('DataService.update', table, id, data)
37
+ end
38
+
39
+ # Deletes the record (specified by id) in the given table from the database.
40
+ #
41
+ # @param [String] table
42
+ # @param [Integer] id
43
+ # @return [Boolean] returns true/false if the record was successfully deleted
44
+ def data_delete(table, id)
45
+ response = get('DataService.delete', table, id)
46
+ end
47
+
48
+ # This will locate all records in a given table that match the criteria for a given field.
49
+ #
50
+ # @param [String] table
51
+ # @param [Integer] limit how many records you would like to return (max is 1000)
52
+ # @param [Integer] page the page of results (each page is max 1000 records)
53
+ # @param [String] field_name
54
+ # @param [String, Integer, Date] field_value
55
+ # @param [Array] selected_fields
56
+ # @return [Array<Hash>] returns the array of records with a hash of the fields and values
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,
59
+ field_value, selected_fields)
60
+ end
61
+
62
+ # Queries records in a given table to find matches on certain fields.
63
+ #
64
+ # @param [String] table
65
+ # @param [Integer] limit
66
+ # @param [Integer] page
67
+ # @param [Hash] data the data you would like to query on. { :FirstName => 'first_name' }
68
+ # @param [Array] selected_fields the fields and values you want back
69
+ # @return [Array<Hash>] the fields and associated values
70
+ def data_query(table, limit, page, data, selected_fields)
71
+ response = get('DataService.query', table, limit, page, data, selected_fields)
72
+ end
73
+
74
+ # Queries records in a given table to find matches on certain fields.
75
+ #
76
+ # @param [String] table
77
+ # @param [Integer] limit
78
+ # @param [Integer] page
79
+ # @param [Hash] data the data you would like to query on. { :FirstName => 'first_name' }
80
+ # @param [Array] selected_fields the fields and values you want back
81
+ # @param [String] field to order by
82
+ # @param [Boolean] ascending
83
+ # @return [Array<Hash>] the fields and associated values
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)
86
+ end
87
+
88
+
89
+ # Adds a custom field to Infusionsoft
90
+ #
91
+ # @param [String] field_type options include Person, Company, Affiliate, Task/Appt/Note,
92
+ # Order, Subscription, or Opportunity
93
+ # @param [String] name
94
+ # @param [String] data_type the type of field Text, Dropdown, TextArea
95
+ # @param [Integer] header_id see notes here
96
+ # http://help.infusionsoft.com/developers/services-methods/data/addCustomField
97
+ def data_add_custom_field(field_type, name, data_type, header_id)
98
+ response = get('DataService.addCustomField', field_type, name, data_type, header_id)
99
+ end
100
+
101
+ # Authenticate an Infusionsoft username and password(md5 hash). If the credentials match
102
+ # it will return back a User ID, if the credentials do not match it will send back an
103
+ # error message
104
+ #
105
+ # @param [String] username
106
+ # @param [String] password
107
+ # @return [Integer] id of the authenticated user
108
+ def data_authenticate_user(username, password)
109
+ response = get('DataService.authenticateUser', username, password)
110
+ end
111
+
112
+ # This method will return back the data currently configured in a user configured
113
+ # application setting.
114
+ #
115
+ # @param [String] module
116
+ # @param [String] setting
117
+ # @return [String] current values in given application setting
118
+ # @note to find the module and option names, view the HTML field name within the Infusionsoft
119
+ # settings. You will see something such as name="Contact_WebModule0optiontypes" . The portion
120
+ # before the underscore is the module name. "Contact" in this example. The portion after the
121
+ # 0 is the setting name, "optiontypes" in this example.
122
+ def data_get_app_setting(module_name, setting)
123
+ response = get('DataService.getAppSetting', module_name, setting)
124
+ end
125
+
126
+ # Returns a temporary API key if given a valid Vendor key and user credentials.
127
+ #
128
+ # @param [String] vendor_key
129
+ # @param [String] username
130
+ # @param [String] password_hash an md5 hash of users password
131
+ # @return [String] temporary API key
132
+ def data_get_temporary_key(vendor_key, username, password_hash)
133
+ response = get('DataService.getTemporaryKey', username, password_hash)
134
+ end
135
+
136
+ # Updates a custom field. Every field can have it’s display name and group id changed,
137
+ # but only certain data types will allow you to change values(dropdown, listbox, radio, etc).
138
+ #
139
+ # @param [Integer] field_id
140
+ # @param [Hash] field_values
141
+ # @return [Boolean] returns true/false if it was updated
142
+ def data_update_custom_field(field_id, field_values)
143
+ response = get('DataService.updateCustomField', field_id, field_values)
144
+ end
145
+ end
146
+ end
147
+ end