infusionsoft 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +9 -0
- data/Gemfile +12 -0
- data/LICENSE.md +0 -2
- data/README.md +17 -21
- data/Rakefile +12 -2
- data/infusionsoft.gemspec +2 -2
- data/lib/infusionsoft/client.rb +2 -0
- data/lib/infusionsoft/client/contact.rb +15 -5
- data/lib/infusionsoft/client/email.rb +1 -1
- data/lib/infusionsoft/client/funnel.rb +18 -0
- data/lib/infusionsoft/client/invoice.rb +1 -1
- data/lib/infusionsoft/connection.rb +1 -1
- data/lib/infusionsoft/request.rb +1 -0
- data/lib/infusionsoft/version.rb +1 -1
- data/test/client/contact_test.rb +79 -0
- data/test/client/data_test.rb +102 -0
- data/test/client/email_test.rb +89 -0
- data/test/exceptions_test.rb +131 -0
- data/test/test_helper.rb +47 -0
- data/test/vcr_cassettes/add_to_group.yml +49 -0
- data/test/vcr_cassettes/contact_add.yml +93 -0
- data/test/vcr_cassettes/contact_add_dup_check_no_dup.yml +93 -0
- data/test/vcr_cassettes/contact_add_dup_check_with_dup.yml +186 -0
- data/test/vcr_cassettes/contact_load.yml +49 -0
- data/test/vcr_cassettes/contact_merge.yml +49 -0
- data/test/vcr_cassettes/contact_update.yml +95 -0
- data/test/vcr_cassettes/data_add.yml +49 -0
- data/test/vcr_cassettes/data_add_custom_field.yml +49 -0
- data/test/vcr_cassettes/data_auth_user_failure.yml +50 -0
- data/test/vcr_cassettes/data_auth_user_success.yml +49 -0
- data/test/vcr_cassettes/data_delete.yml +49 -0
- data/test/vcr_cassettes/data_find_by_field.yml +51 -0
- data/test/vcr_cassettes/data_get_app_setting.yml +50 -0
- data/test/vcr_cassettes/data_load.yml +51 -0
- data/test/vcr_cassettes/data_query.yml +51 -0
- data/test/vcr_cassettes/data_query_order_by.yml +51 -0
- data/test/vcr_cassettes/data_update.yml +96 -0
- data/test/vcr_cassettes/data_update_custom_field.yml +49 -0
- data/test/vcr_cassettes/email_add.yml +50 -0
- data/test/vcr_cassettes/email_attach.yml +50 -0
- data/test/vcr_cassettes/email_get_available_merge_fields.yml +52 -0
- data/test/vcr_cassettes/email_get_opt_status.yml +50 -0
- data/test/vcr_cassettes/email_get_template.yml +118 -0
- data/test/vcr_cassettes/email_optin.yml +50 -0
- data/test/vcr_cassettes/email_optout.yml +50 -0
- data/test/vcr_cassettes/email_send.yml +50 -0
- data/test/vcr_cassettes/email_send_template.yml +50 -0
- data/test/vcr_cassettes/email_update_template.yml +50 -0
- data/test/vcr_cassettes/find_by_email.yml +49 -0
- data/test/vcr_cassettes/remove_from_group.yml +49 -0
- metadata +50 -17
- data/test/api_infusion_test.rb +0 -8
- data/test/test_exceptions.rb +0 -113
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5093b99e37a3b833ebe5904cdfa74630f606cfc
|
4
|
+
data.tar.gz: 40a88c2dcc0209bf00d22df7c3f9d608451a0e0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94d51f850e3a136432d7bdb87876ce5ca0c62876b6279e086a882eb7551c29238459f67ce6de0388037dcb92ea7dd3c01613338a4b2e817f27782d4d97ce184d
|
7
|
+
data.tar.gz: acf786d0578fd6d3f446bd6c3db04e11ee7041b39de384ab3e4ec9f002801ac37af4e72800a66b10f3a3969e20c6cf991f492d16b830477b252ae90ff80b88c1
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2013 Nathan Leavitt
|
4
|
-
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
4
|
of this software and associated documentation files (the "Software"), to deal
|
7
5
|
in the Software without restriction, including without limitation the rights
|
data/README.md
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/nateleavitt/infusionsoft.svg?branch=master)](https://travis-ci.org/nateleavitt/infusionsoft)
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/nateleavitt/infusionsoft/badge.svg?branch=master&service=github)](https://coveralls.io/github/nateleavitt/infusionsoft?branch=master)
|
3
|
+
|
4
|
+
|
1
5
|
# The Infusionsoft Ruby Gem
|
2
6
|
A Ruby wrapper for the Infusionsoft API
|
3
7
|
|
4
8
|
**update notes**
|
5
|
-
|
9
|
+
* Currently - 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.
|
10
|
+
* 07/21/2015 - Implementation of tests and build/coverage (Thanks! @TheMetalCode)
|
11
|
+
* v1.1.8 - Added a default user-agent in the headers. Also, give the
|
12
|
+
ability to set your own user-agent in the config block.
|
6
13
|
* v1.1.5 - Added a custom logger option. This will allow you to track all api calls/results in a separate log file. Defaults to $stdout if none is specified. To add logger specify `api_logger` in your [config block](#setup--configuration).
|
7
14
|
|
8
15
|
## <a name="installation">Installation</a>
|
@@ -12,14 +19,14 @@ A Ruby wrapper for the Infusionsoft API
|
|
12
19
|
[http://rubydoc.info/gems/infusionsoft/frames](http://rubydoc.info/gems/infusionsoft/frames)
|
13
20
|
|
14
21
|
## <a name="setup">Setup & Configuration</a>
|
15
|
-
1. **Rails 2.3** - add `config.gem 'infusionsoft'` **Rails 3** - add `'infusionsoft'` to your `Gemfile`
|
22
|
+
1. **Rails 2.3** - add `config.gem 'infusionsoft'` **Rails >= 3** - add `'infusionsoft'` to your `Gemfile`
|
16
23
|
2. Then create an initializer in `config\initializers` called infusionsoft.rb and the following
|
17
24
|
|
18
25
|
<b></b>
|
19
26
|
|
20
27
|
# Added to your config\initializers file
|
21
28
|
Infusionsoft.configure do |config|
|
22
|
-
config.api_url = 'YOUR_INFUSIONSOFT_URL' # example infused.infusionsoft.com
|
29
|
+
config.api_url = 'YOUR_INFUSIONSOFT_URL' # example infused.infusionsoft.com DO NOT INCLUDE https://
|
23
30
|
config.api_key = 'YOUR_INFUSIONSOFT_API_KEY'
|
24
31
|
config.api_logger = Logger.new("#{Rails.root}/log/infusionsoft_api.log") # optional logger file
|
25
32
|
end
|
@@ -29,6 +36,10 @@ A Ruby wrapper for the Infusionsoft API
|
|
29
36
|
# Get a users first and last name using the DataService
|
30
37
|
Infusionsoft.data_load('Contact', contact_id, [:FirstName, :LastName])
|
31
38
|
|
39
|
+
# Get a list of custom fields
|
40
|
+
Infusionsoft.data_find_by_field('DataFormField', 100, 0, 'FormId', -1, ['Name'])
|
41
|
+
# Note, when updating custom fields they are case sensisitve and need to be prefaced with a '_'
|
42
|
+
|
32
43
|
# Update a contact with specific field values
|
33
44
|
Infusionsoft.contact_update(contact_id, { :FirstName => 'first_name', :Email => 'test@test.com' })
|
34
45
|
|
@@ -62,27 +73,12 @@ Here are some ways *you* can contribute:
|
|
62
73
|
|
63
74
|
## <a name="issues">Submitting an Issue</a>
|
64
75
|
We use the [GitHub issue tracker](https://github.com/nateleavitt/infusionsoft/issues) to track bugs and
|
65
|
-
features.
|
66
|
-
been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
|
67
|
-
bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
|
68
|
-
details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
|
69
|
-
operating system. Ideally, a bug report should include a pull request with failing specs.
|
70
|
-
|
71
|
-
## <a name="pulls">Submitting a Pull Request</a>
|
72
|
-
1. Fork the project.
|
73
|
-
2. Create a topic branch.
|
74
|
-
3. Implement your feature or bug fix.
|
75
|
-
4. Add documentation for your feature or bug fix.
|
76
|
-
5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
|
77
|
-
6. Add specs for your feature or bug fix.
|
78
|
-
7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
|
79
|
-
8. Commit and push your changes.
|
80
|
-
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.)
|
76
|
+
features.
|
81
77
|
|
82
78
|
## <a name="rubies">Supported Rubies</a>
|
83
79
|
This library aims to support the following Ruby implementations:
|
84
80
|
|
85
|
-
* Ruby = 1.8.7
|
81
|
+
* Ruby = 1.8.7 (It will work, but tests require Ruby >= 1.9)
|
86
82
|
* Ruby >= 1.9
|
87
83
|
* [JRuby](http://www.jruby.org/)
|
88
84
|
* [Rubinius](http://rubini.us/)
|
@@ -107,7 +103,7 @@ time of a major release, support for that Ruby version may be dropped.
|
|
107
103
|
* Need to add a history log for additional contributers
|
108
104
|
|
109
105
|
## <a name="copyright">Copyright</a>
|
110
|
-
Copyright (c)
|
106
|
+
Copyright (c) 2015 Nathan Leavitt
|
111
107
|
|
112
108
|
See [LICENSE](https://github.com/nateleavitt/infusionsoft/blob/master/LICENSE.md) for details.
|
113
109
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'rake/testtask'
|
2
3
|
|
3
|
-
Rake::TestTask.new
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
t.test_files = FileList['test/*_test.rb', 'test/**/*_test.rb']
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
rescue LoadError
|
10
|
+
#no test-unit available
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: [:test]
|
data/infusionsoft.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.summary = %q{Ruby wrapper for the Infusionsoft API}
|
7
7
|
gem.description = 'A Ruby wrapper written for the Infusionsoft API'
|
8
8
|
gem.authors = ["Nathan Leavitt"]
|
9
|
-
gem.email = ['
|
10
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
9
|
+
gem.email = ['nateleavitt@gmail.com']
|
10
|
+
# gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
11
11
|
gem.files = `git ls-files`.split("\n")
|
12
12
|
gem.homepage = 'https://github.com/nateleavitt/infusionsoft'
|
13
13
|
gem.require_paths = ['lib']
|
data/lib/infusionsoft/client.rb
CHANGED
@@ -15,6 +15,7 @@ module Infusionsoft
|
|
15
15
|
require 'infusionsoft/client/ticket' # Deprecated by Infusionsoft
|
16
16
|
require 'infusionsoft/client/search'
|
17
17
|
require 'infusionsoft/client/credit_card'
|
18
|
+
require 'infusionsoft/client/funnel'
|
18
19
|
|
19
20
|
include Infusionsoft::Client::Contact
|
20
21
|
include Infusionsoft::Client::Email
|
@@ -25,5 +26,6 @@ module Infusionsoft
|
|
25
26
|
include Infusionsoft::Client::Ticket # Deprecated by Infusionsoft
|
26
27
|
include Infusionsoft::Client::Search
|
27
28
|
include Infusionsoft::Client::CreditCard
|
29
|
+
include Infusionsoft::Client::Funnel
|
28
30
|
end
|
29
31
|
end
|
@@ -11,9 +11,17 @@ module Infusionsoft
|
|
11
11
|
# { :Email => 'test@test.com', :FirstName => 'first_name', :LastName => 'last_name' }
|
12
12
|
def contact_add(data)
|
13
13
|
contact_id = get('ContactService.add', data)
|
14
|
-
if data.has_key?(
|
14
|
+
if data.has_key?(:Email); email_optin(data[:Email], "requested information"); end
|
15
15
|
return contact_id
|
16
16
|
end
|
17
|
+
|
18
|
+
# Merge two contacts together.
|
19
|
+
#
|
20
|
+
# @param [Integer] contact_id
|
21
|
+
# @param [Integer] duplicate_contact_id
|
22
|
+
def contact_merge(contact_id, duplicate_contact_id)
|
23
|
+
response = get('ContactService.merge', contact_id, duplicate_contact_id)
|
24
|
+
end
|
17
25
|
|
18
26
|
# Adds or updates a contact record based on matching data
|
19
27
|
#
|
@@ -22,7 +30,9 @@ module Infusionsoft
|
|
22
30
|
# 'EmailAndNameAndCompany'
|
23
31
|
# @return [Integer] id of the contact added or updated
|
24
32
|
def contact_add_with_dup_check(data, check_type)
|
25
|
-
|
33
|
+
contact_id = get('ContactService.addWithDupCheck', data, check_type)
|
34
|
+
if data.has_key?(:Email); email_optin(data[:Email], "requested information"); end
|
35
|
+
return contact_id
|
26
36
|
end
|
27
37
|
|
28
38
|
# Updates a contact in the database.
|
@@ -33,9 +43,9 @@ module Infusionsoft
|
|
33
43
|
# @example
|
34
44
|
# { :FirstName => 'first_name', :StreetAddress1 => '123 N Street' }
|
35
45
|
def contact_update(contact_id, data)
|
36
|
-
|
37
|
-
if data.has_key?(
|
38
|
-
return
|
46
|
+
contact_id = get('ContactService.update', contact_id, data)
|
47
|
+
if data.has_key?(:Email); email_optin(data[:Email], "requested information"); end
|
48
|
+
return contact_id
|
39
49
|
end
|
40
50
|
|
41
51
|
# Loads a contact from the database
|
@@ -123,7 +123,7 @@ module Infusionsoft
|
|
123
123
|
# @param [String] The Id of the template to send
|
124
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.
|
126
|
+
response = get('APIEmailService.sendEmail', contact_list, template_id)
|
127
127
|
end
|
128
128
|
|
129
129
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Infusionsoft
|
2
|
+
class Client
|
3
|
+
# Funnel Service is used to add contacts to your sequences
|
4
|
+
module Funnel
|
5
|
+
|
6
|
+
# Achieves a goal, Returns the result of a goal being achieved.
|
7
|
+
#
|
8
|
+
# @param integration, string, The integration name of the goal. This defaults to the name of the app.
|
9
|
+
# @param call_name, string, The call name of the goal
|
10
|
+
# @param cid, int, The id of the contact you want to add to a sequence.
|
11
|
+
#
|
12
|
+
def funnel_achieve_goal(integration, call_name, cid)
|
13
|
+
response = get('FunnelService.achieveGoal', integration, call_name, cid)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -40,7 +40,7 @@ module Infusionsoft
|
|
40
40
|
# @param [Integer] credit_card_id
|
41
41
|
# @param [Integer] merchant_account_id
|
42
42
|
# @param [Boolean] bypass_commission
|
43
|
-
# @return [Hash] containing the following keys {'Successful => [Boolean],
|
43
|
+
# @return [Hash] containing the following keys {'Successful' => [Boolean],
|
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)
|
@@ -14,7 +14,7 @@ module Infusionsoft
|
|
14
14
|
})
|
15
15
|
client.http_header_extra = {'User-Agent' => user_agent}
|
16
16
|
begin
|
17
|
-
api_logger.info "CALL: #{service_call} api_key:#{api_key} at:#{Time.now} args:#{args.inspect}"
|
17
|
+
api_logger.info "CALL: #{service_call} api_url: #{api_url} api_key:#{api_key} at:#{Time.now} args:#{args.inspect}"
|
18
18
|
result = client.call("#{service_call}", api_key, *args)
|
19
19
|
if result.nil?; ok_to_retry('nil response') end
|
20
20
|
rescue Timeout::Error => timeout
|
data/lib/infusionsoft/request.rb
CHANGED
data/lib/infusionsoft/version.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative('../test_helper')
|
2
|
+
|
3
|
+
class ContactTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_contact_add
|
6
|
+
data_hash = { Email: 'test@tester.com', FirstName: 'Severus', LastName: 'Snape' }
|
7
|
+
VCR.use_cassette('contact_add') do
|
8
|
+
result = Infusionsoft.contact_add(data_hash)
|
9
|
+
assert_instance_of Fixnum, result
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_contact_merge
|
14
|
+
VCR.use_cassette('contact_merge') do
|
15
|
+
result = Infusionsoft.contact_merge(3602, 3604)
|
16
|
+
assert_true result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_contact_add_dup_check_with_dup
|
21
|
+
data_hash = { Email: 'test@tester.com', FirstName: 'Severus',
|
22
|
+
LastName: 'Snape', Company: 'Test Company' }
|
23
|
+
VCR.use_cassette('contact_add_dup_check_with_dup') do
|
24
|
+
existing_contact = Infusionsoft.contact_load(3606, [:Id, :FirstName, :LastName, :Email, :Company])
|
25
|
+
result = Infusionsoft.contact_add_with_dup_check(data_hash, 'EmailAndName')
|
26
|
+
assert_equal result, existing_contact['Id']
|
27
|
+
assert_equal Infusionsoft.contact_load(existing_contact['Id'], [:Company])['Company'], data_hash[:Company]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_contact_add_dup_check_no_dup
|
32
|
+
data_hash = { Email: 'new@tester.com', FirstName: 'Albus',
|
33
|
+
LastName: 'Dumbledore', Company: 'Hogwarts' }
|
34
|
+
VCR.use_cassette('contact_add_dup_check_no_dup') do
|
35
|
+
result = Infusionsoft.contact_add_with_dup_check(data_hash, 'EmailAndNameAndCompany')
|
36
|
+
assert_instance_of Fixnum, result
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_contact_load
|
41
|
+
desired_fields = [:FirstName, :LastName]
|
42
|
+
expected_fields = desired_fields.map { |f| f.to_s }.sort
|
43
|
+
VCR.use_cassette('contact_load') do
|
44
|
+
result = Infusionsoft.contact_load(3606, desired_fields)
|
45
|
+
assert_equal result.keys.sort, expected_fields
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_contact_update
|
50
|
+
data_hash = { Company: 'Hogwarts' }
|
51
|
+
VCR.use_cassette('contact_update') do
|
52
|
+
result = Infusionsoft.contact_update(3606, data_hash)
|
53
|
+
assert_equal result, 3606
|
54
|
+
assert_equal Infusionsoft.contact_load(3606, [:Company])['Company'], data_hash[:Company]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_contact_find_by_email
|
59
|
+
VCR.use_cassette('find_by_email') do
|
60
|
+
result = Infusionsoft.contact_find_by_email('test@tester.com', [:Id])
|
61
|
+
assert_instance_of Array, result
|
62
|
+
assert_instance_of Hash, result.first
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_contact_add_to_group
|
67
|
+
VCR.use_cassette('add_to_group') do
|
68
|
+
result = Infusionsoft.contact_add_to_group(3794, 382)
|
69
|
+
assert_true result
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_contact_remove_from_group
|
74
|
+
VCR.use_cassette('remove_from_group') do
|
75
|
+
result = Infusionsoft.contact_remove_from_group(3794, 382)
|
76
|
+
assert_true result
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require_relative('../test_helper')
|
2
|
+
|
3
|
+
class DataTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_data_add
|
6
|
+
data_hash = { Company: 'Hogwarts of America', Phone1: '123-456-7899',
|
7
|
+
Website: 'http://hogwarts-usa.com', StreetAddress1: '123 Wizard Ave.',
|
8
|
+
City: 'Redmond', State: 'WA', PostalCode: '98052',
|
9
|
+
Country: 'United States' }
|
10
|
+
VCR.use_cassette('data_add') do
|
11
|
+
result = Infusionsoft.data_add('Company', data_hash)
|
12
|
+
assert_instance_of Fixnum, result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_data_load
|
17
|
+
desired_fields = [:Company, :StreetAddress1, :City, :State, :PostalCode, :Country]
|
18
|
+
expected_fields = desired_fields.map { |f| f.to_s }.sort
|
19
|
+
VCR.use_cassette('data_load') do
|
20
|
+
result = Infusionsoft.data_load('Company', 3618, desired_fields)
|
21
|
+
assert_equal result.keys.sort, expected_fields
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_data_update
|
26
|
+
update_hash = { Phone1: '(987) 654-3211' }
|
27
|
+
VCR.use_cassette('data_update') do
|
28
|
+
result = Infusionsoft.data_update('Company', 3618, update_hash)
|
29
|
+
assert_equal result, 3618
|
30
|
+
assert_equal Infusionsoft.data_load('Company', 3618, [:Phone1])['Phone1'], update_hash[:Phone1]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_data_delete
|
35
|
+
VCR.use_cassette('data_delete') do
|
36
|
+
result = Infusionsoft.data_delete('Company', 3618)
|
37
|
+
assert_true result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_data_find_by_field
|
42
|
+
VCR.use_cassette('data_find_by_field') do
|
43
|
+
result = Infusionsoft.data_find_by_field('Company', 5, 0, :Company, 'Hogwarts of America', [:Id, :Company])
|
44
|
+
assert_instance_of Array, result
|
45
|
+
assert_compare result.size, :>, 0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_data_query
|
50
|
+
VCR.use_cassette('data_query') do
|
51
|
+
result = Infusionsoft.data_query('Company', 5, 0, { :Company => 'Hogwarts of America' }, [:Id, :Company])
|
52
|
+
assert_instance_of Array, result
|
53
|
+
assert_compare result.size, :>, 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_data_query_order_by
|
58
|
+
VCR.use_cassette('data_query_order_by') do
|
59
|
+
result = Infusionsoft.data_query_order_by('Company', 5, 0, { :Company => 'Hogwarts of America' }, [:Id, :Company], :Id, false)
|
60
|
+
assert_instance_of Array, result
|
61
|
+
assert_compare result.size, :>, 0
|
62
|
+
assert_compare result.first['Id'].to_i, :>, result.last['Id'].to_i
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_data_add_custom_field
|
67
|
+
VCR.use_cassette('data_add_custom_field') do
|
68
|
+
result = Infusionsoft.data_add_custom_field('Company', 'Awesomeness Level', 'Text', 4)
|
69
|
+
assert_instance_of Fixnum, result
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_data_auth_user_success
|
74
|
+
password = Digest::MD5.new.hexdigest 'good_pass'
|
75
|
+
VCR.use_cassette('data_auth_user_success') do
|
76
|
+
result = Infusionsoft.data_authenticate_user('test@test.com', password)
|
77
|
+
assert_instance_of Fixnum, result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_data_auth_user_failure
|
82
|
+
VCR.use_cassette('data_auth_user_failure') do
|
83
|
+
assert_raise_kind_of Infusionsoft::FailedLoginAttemptError do
|
84
|
+
Infusionsoft.data_authenticate_user('test@test.com', 'bad_pass')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_data_update_custom_field
|
90
|
+
VCR.use_cassette('data_update_custom_field') do
|
91
|
+
result = Infusionsoft.data_update_custom_field(16, {:Label => 'Stuff'} )
|
92
|
+
assert_true result
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_data_get_app_setting
|
97
|
+
VCR.use_cassette('data_get_app_setting') do
|
98
|
+
result = Infusionsoft.data_get_app_setting('Contact', 'optiontitles')
|
99
|
+
assert_not_nil result
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|