legacy_infusionsoft_api 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11a960f09f2c4769d53e7394ff51ce5865846a63
4
+ data.tar.gz: 38df3806b477286cf1da892d83d0940d14d58403
5
+ SHA512:
6
+ metadata.gz: 97535fe9ed1758b1b56e44738c997c19d24e964f3b46a9dfdd0ef7ae3115822be5773be97006246804595ac6ee5dfa88516ad6defbdeecb6b1bcd1c7be49c40e
7
+ data.tar.gz: 26dcb32dee06fe9a0216050a1c33c86e1fae692ab8dee08ce09b5b3815a9ada85fd2cfd6c305b0eaece8e3fa8b9d24f9d20f67cd6e23b4f8934f8fba59b1f060
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,93 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - '**/bin/*'
8
+
9
+ # Prefer &&/|| over and/or.
10
+ Style/AndOr:
11
+ Enabled: true
12
+
13
+ # Do not use braces for hash literals when they are the last argument of a
14
+ # method call.
15
+ Style/BracesAroundHashParameters:
16
+ Enabled: true
17
+
18
+ # Align `when` with `case`.
19
+ Layout/CaseIndentation:
20
+ Enabled: true
21
+
22
+ # No extra empty lines.
23
+ Layout/EmptyLines:
24
+ Enabled: true
25
+
26
+ # In a regular class definition, no empty lines around the body.
27
+ Layout/EmptyLinesAroundClassBody:
28
+ Enabled: true
29
+
30
+ # In a regular module definition, no empty lines around the body.
31
+ Layout/EmptyLinesAroundModuleBody:
32
+ Enabled: true
33
+
34
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
35
+ Style/HashSyntax:
36
+ Enabled: true
37
+
38
+ # Method definitions after `private` or `protected` isolated calls need one
39
+ # extra level of indentation.
40
+ Layout/IndentationConsistency:
41
+ Enabled: true
42
+ EnforcedStyle: rails
43
+
44
+ # Two spaces, no tabs (for indentation).
45
+ Layout/IndentationWidth:
46
+ Enabled: true
47
+
48
+ # Defining a method with parameters needs parentheses.
49
+ Style/MethodDefParentheses:
50
+ Enabled: true
51
+
52
+ # Use `foo {}` not `foo{}`.
53
+ Layout/SpaceBeforeBlockBraces:
54
+ Enabled: true
55
+
56
+ # Use `foo { bar }` not `foo {bar}`.
57
+ Layout/SpaceInsideBlockBraces:
58
+ Enabled: true
59
+
60
+ # Use `{ a: 1 }` not `{a:1}`.
61
+ Layout/SpaceInsideHashLiteralBraces:
62
+ Enabled: true
63
+
64
+ # Check quotes usage according to lint rule below.
65
+ Style/StringLiterals:
66
+ Enabled: true
67
+ EnforcedStyle: double_quotes
68
+
69
+ # Detect hard tabs, no hard tabs.
70
+ Layout/Tab:
71
+ Enabled: true
72
+
73
+ # Blank lines should not have any spaces.
74
+ Layout/TrailingBlankLines:
75
+ Enabled: true
76
+
77
+ # No trailing whitespace.
78
+ Layout/TrailingWhitespace:
79
+ Enabled: true
80
+
81
+ # Use quotes for string literals when they are enough.
82
+ Style/UnneededPercentQ:
83
+ Enabled: true
84
+
85
+ # Align `end` with the matching keyword or starting expression except for
86
+ # assignments, where it should be aligned with the LHS.
87
+ Lint/EndAlignment:
88
+ Enabled: true
89
+ EnforcedStyleAlignWith: variable
90
+
91
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
92
+ Lint/RequireParentheses:
93
+ Enabled: true
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at cavneb@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in legacy_infusionsoft_api.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Eric Berry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # Ruby client for Legacy XML-RPC Infusionsoft Api
2
+
3
+ <a href="https://app.codesponsor.io/link/Z24Ypyn8iC1Q4i6uCwNyLW3r/cavneb/legacy_infusionsoft_api" rel="nofollow"><img src="https://app.codesponsor.io/embed/Z24Ypyn8iC1Q4i6uCwNyLW3r/cavneb/legacy_infusionsoft_api.svg" style="width: 888px; height: 68px;" alt="Sponsor" /></a>
4
+
5
+ [Legacy Infusionsoft Api](https://github.com/cavneb/legacy_infusionsoft_api) is an interface for accessing [Infusionsoft's](http://help.infusionsoft.com/developers/api-basics) API.
6
+
7
+ It's based on the [MYOB Api](https://github.com/davidlumley/myob-api) gem and the [Infusionsoft API](https://github.com/davidlumley/infusionsoft-api) gem.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'legacy_infusionsoft_api'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install legacy_infusionsoft_api
24
+
25
+ ## Usage
26
+
27
+ ### API Client Setup
28
+
29
+ Create an api_client:
30
+
31
+ api_client = LegacyInfusionsoftApi::Client.new({
32
+ api_key: USERS_API_KEY,
33
+ app_name: USERS_APP_NAME,
34
+ })
35
+
36
+ The `:api_key` can be found in Infusionsoft under Admin -> Settings -> Application Setttings (Application). The `:app_name` is the subdomain of `app_name.infusionsoft.com`('app_name').
37
+
38
+ ### API Methods
39
+
40
+ #### Contacts
41
+
42
+ Return a list of all contacts
43
+
44
+ api_client.contact.all
45
+
46
+ You can get a count of all contacts
47
+
48
+ api_client.contact.count
49
+
50
+ You can execute a block of code while iterating contacts
51
+
52
+ api_client.contact.find_each({}, true, 50) do |contacts|
53
+ # contacts.length === 50
54
+ contacts.each do |contact|
55
+ puts contact['Id']
56
+ end
57
+ end
58
+
59
+ You can also pass a query hash
60
+
61
+ api_client.contact.all({
62
+ :FirstName => 'David',
63
+ })
64
+
65
+ You can create contacts too
66
+
67
+ client = api_client.contact.create({
68
+ :FirstName => 'David',
69
+ :LastName => 'Lumley',
70
+ :Email => 'david@davidlumley.com.au',
71
+ :Company => 'Client Heartbeat',
72
+ })
73
+
74
+ You can also delete contacts by passing an ID
75
+
76
+ api_client.contact.delete(16)
77
+
78
+ Or by passing a query
79
+
80
+ api_client.contact.delete({
81
+ :FirstName => 'Trevor',
82
+ })
83
+
84
+ #### Contact Groups
85
+
86
+ Return a list of all contact groups
87
+
88
+ api_client.contact_group_assign.all
89
+
90
+ You can also pass a hash query
91
+
92
+ api_client.contact_group_assign.all({
93
+ :GroupCategoryId => 12,
94
+ })
95
+
96
+ #### Contact Group Assignments
97
+
98
+ Return a list of all contact group assignments (i.e. contacts with a tag or group)
99
+
100
+ api_client.contact_group_assign.all
101
+
102
+ You can also pass a hash query
103
+
104
+ api_client.contact_group_assign.all({
105
+ :ContactGroup => 'New Customer',
106
+ })
107
+
108
+ #### Contact Group Categories
109
+
110
+ Return a list of all contact group categories
111
+
112
+ api_client.contact_group_category.all
113
+
114
+ You can also pass a hash query
115
+
116
+ api_client.contact_group_category.all({
117
+ :CategoryName => 'Custom Tags',
118
+ })
119
+
120
+ ## Development
121
+
122
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
123
+
124
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
125
+
126
+ ## Contributing
127
+
128
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/legacy_infusionsoft_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
129
+
130
+ ## License
131
+
132
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
133
+
134
+ ## Code of Conduct
135
+
136
+ Everyone interacting in the LegacyInfusionsoftApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/legacy_infusionsoft_api/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "legacy_infusionsoft_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "legacy_infusionsoft_api/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "legacy_infusionsoft_api"
8
+ spec.version = LegacyInfusionsoftApi::VERSION
9
+ spec.authors = ["Eric Berry"]
10
+ spec.email = ["cavneb@gmail.com"]
11
+
12
+ spec.summary = "Legacy Infusionsoft API"
13
+ spec.description = "Ruby client for Legacy XML-RPC Infusionsoft API"
14
+ spec.homepage = "https://github.com/cavneb/legacy_infusionsoft_api"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "xmlrpc", "~> 0.3.0"
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "minitest", "~> 5.0"
28
+ spec.add_development_dependency "rubocop", "~> 0.49"
29
+ end
@@ -0,0 +1,8 @@
1
+ require "legacy_infusionsoft_api/version"
2
+ require "legacy_infusionsoft_api/helpers"
3
+ require "legacy_infusionsoft_api/models/base"
4
+ require "legacy_infusionsoft_api/models/contact"
5
+ require "legacy_infusionsoft_api/models/contact_group"
6
+ require "legacy_infusionsoft_api/models/contact_group_assign"
7
+ require "legacy_infusionsoft_api/models/contact_group_category"
8
+ require "legacy_infusionsoft_api/client"
@@ -0,0 +1,23 @@
1
+ require "xmlrpc/client"
2
+
3
+ module LegacyInfusionsoftApi
4
+ class Client
5
+ include LegacyInfusionsoftApi::Helpers
6
+
7
+ attr_reader :api_key, :app_name
8
+
9
+ def initialize(options)
10
+ model :Contact
11
+ model :ContactGroup
12
+ model :ContactGroupAssign
13
+ model :ContactGroupCategory
14
+
15
+ @api_key = options[:api_key]
16
+ @app_name = options[:app_name]
17
+ end
18
+
19
+ def connection
20
+ @client ||= XMLRPC::Client.new2("https://#{@app_name}.infusionsoft.com:443/api/xmlrpc")
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ class String
2
+ def underscore
3
+ self.gsub(/::/, "/").
4
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
+ tr("-", "_").
7
+ downcase
8
+ end
9
+ end
10
+
11
+ module LegacyInfusionsoftApi::Helpers
12
+ def model(model_name)
13
+ variable_name = "@#{model_name.to_s.underscore}_model".to_sym
14
+ unless instance_variable_defined?(variable_name)
15
+ instance_variable_set(variable_name, LegacyInfusionsoftApi::Model.const_get("#{model_name}".to_sym).new(self, model_name.to_s))
16
+ self.define_singleton_method("#{model_name.to_s.underscore}".to_sym) do
17
+ instance_variable_get(variable_name)
18
+ end
19
+ end
20
+ instance_variable_get(variable_name)
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ module LegacyInfusionsoftApi::Model
2
+ class Base
3
+ def initialize(client, model_name)
4
+ @client = client
5
+ @model_name = model_name || "Base"
6
+ end
7
+
8
+ def all(query = {}, paginate = true, per_page = 1000, page_number = 0)
9
+ per_page = [per_page, 1000].min
10
+ results = @client.connection.call("DataService.query", @client.api_key, self.table_name, per_page, page_number, query, self.fields)
11
+ results.length > 0 && paginate ? results + self.all(query, true, per_page, page_number + 1) : results
12
+ end
13
+
14
+ def find_each(query = {}, paginate = true, per_page = 1000, page_number = 0, &block)
15
+ per_page = [per_page, 1000].min
16
+ results = @client.connection.call("DataService.query", @client.api_key, self.table_name, per_page, page_number, query, self.fields)
17
+ yield results
18
+ return self.find_each(query, true, per_page, page_number + 1, &block) if results.length > 0 && paginate
19
+ true
20
+ end
21
+
22
+ def first(query = {})
23
+ self.all(query, false)[0]
24
+ end
25
+
26
+ def create(data = {})
27
+ data["Id"] = @client.connection.call("DataService.add", @client.api_key, self.table_name, data)
28
+ data
29
+ end
30
+
31
+ def delete(query)
32
+ if query.is_a?(Hash)
33
+ self.all(query).each { |data| self.delete(data["Id"]) }
34
+ else
35
+ @client.connection.call("DataService.delete", @client.api_key, self.table_name, query)
36
+ end
37
+ end
38
+
39
+ def count(query={})
40
+ @client.connection.call("DataService.count", @client.api_key, self.table_name, query)
41
+ end
42
+
43
+ def table_name
44
+ @model_name
45
+ end
46
+
47
+ def fields
48
+ []
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,16 @@
1
+ module LegacyInfusionsoftApi::Model
2
+ class Contact < LegacyInfusionsoftApi::Model::Base
3
+ def fields
4
+ [ :AccountId, :Address1Type, :Address2Street1, :Address2Street2, :Address2Type, :Address3Street1,
5
+ :Address3Street2, :Address3Type, :Anniversary, :AssistantName, :AssistantPhone, :BillingInformation,
6
+ :Birthday, :City, :City2, :City3, :Company, :CompanyID, :ContactNotes, :ContactType, :Country, :Country2,
7
+ :Country3, :CreatedBy, :DateCreated, :Email, :EmailAddress2, :EmailAddress3, :Fax1, :Fax1Type, :Fax2,
8
+ :Fax2Type, :FirstName, :Groups, :Id, :JobTitle, :Language, :LastName, :LastUpdated, :LastUpdatedBy,
9
+ :LeadSourceId, :Leadsource, :MiddleName, :Nickname, :OwnerID, :Password, :Phone1, :Phone1Ext, :Phone1Type,
10
+ :Phone2, :Phone2Ext, :Phone2Type, :Phone3, :Phone3Ext, :Phone3Type, :Phone4, :Phone4Ext, :Phone4Type,
11
+ :Phone5, :Phone5Ext, :Phone5Type, :PostalCode, :PostalCode2, :PostalCode3, :ReferralCode, :SpouseName,
12
+ :State, :State2, :State3, :StreetAddress1, :StreetAddress2, :Suffix, :TimeZone, :Title, :Username,
13
+ :Validated, :Website, :ZipFour1, :ZipFour2, :ZipFour3 ]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module LegacyInfusionsoftApi::Model
2
+ class ContactGroup < LegacyInfusionsoftApi::Model::Base
3
+ def fields
4
+ [ :Id, :GroupName, :GroupCategoryId, :GroupDescription ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,47 @@
1
+ module LegacyInfusionsoftApi::Model
2
+ class ContactGroupAssign < LegacyInfusionsoftApi::Model::Base
3
+ def all(query = {}, paginate = true, page_number = 0)
4
+ results = super(query, paginate, page_number)
5
+ results.map { |x|{
6
+ "Id" => x["ContactId"],
7
+ "GroupId" => x["GroupId"],
8
+ "FirstName" => x["Contact.FirstName"],
9
+ "LastName" => x["Contact.LastName"],
10
+ "Company" => x["Contact.Company"],
11
+ "Email" => x["Contact.Email"],
12
+ "ContactGroup" => x["ContactGroup"],
13
+ }}
14
+ end
15
+
16
+ def create(data = {})
17
+ data = standardise_query(data)
18
+ @client.connection.call("ContactService.addToGroup", @client.api_key, data[:ContactId], data[:GroupId])
19
+ end
20
+
21
+ def delete(query = {})
22
+ query = standardise_query(query)
23
+ if query[:ContactId] && query[:GroupId]
24
+ @client.connection.call("ContactService.removeFromGroup", @client.api_key, query[:ContactId], query[:GroupId])
25
+ else
26
+ self.all(query).each do |data|
27
+ self.delete( ContactId: data["Id"],
28
+ GroupId: data["GroupId"])
29
+ end
30
+ end
31
+ end
32
+
33
+ def fields
34
+ [:'ContactGroup', :'ContactId', :'GroupId', :'Contact.FirstName', :'Contact.LastName', :'Contact.Company', :'Contact.Email']
35
+ end
36
+
37
+ private
38
+
39
+ def standardise_query(query = {})
40
+ if query["ContactId"] && query["GroupId"]
41
+ query[:ContactId] = query["ContactId"]
42
+ query[:GroupId] = query["GroupId"]
43
+ end
44
+ query
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,7 @@
1
+ module LegacyInfusionsoftApi::Model
2
+ class ContactGroupCategory < LegacyInfusionsoftApi::Model::Base
3
+ def fields
4
+ [ :Id, :CategoryName, :CategoryDescription ]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module LegacyInfusionsoftApi
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: legacy_infusionsoft_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Berry
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xmlrpc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.49'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.49'
83
+ description: Ruby client for Legacy XML-RPC Infusionsoft API
84
+ email:
85
+ - cavneb@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - legacy_infusionsoft_api.gemspec
101
+ - lib/legacy_infusionsoft_api.rb
102
+ - lib/legacy_infusionsoft_api/client.rb
103
+ - lib/legacy_infusionsoft_api/helpers.rb
104
+ - lib/legacy_infusionsoft_api/models/base.rb
105
+ - lib/legacy_infusionsoft_api/models/contact.rb
106
+ - lib/legacy_infusionsoft_api/models/contact_group.rb
107
+ - lib/legacy_infusionsoft_api/models/contact_group_assign.rb
108
+ - lib/legacy_infusionsoft_api/models/contact_group_category.rb
109
+ - lib/legacy_infusionsoft_api/version.rb
110
+ homepage: https://github.com/cavneb/legacy_infusionsoft_api
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.6.13
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Legacy Infusionsoft API
134
+ test_files: []