infusionsoft-api 0.0.3 → 0.0.4

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: 90d3db43eab8c264629313394714cdde003e3867
4
+ data.tar.gz: 7982d2a8d489f61b377aeb67334a79c1cc221934
5
+ SHA512:
6
+ metadata.gz: 53351c629208913d01740fedad2832b2e8c3c4b3cd209f03f58ce52ce12e8a1147423bcd2fda0dae54a307efcf33b24cee3d2b0d4c0b1e62733276124b9af6dd
7
+ data.tar.gz: 88c4d923be209ed34847b17a3a2431744be6de04c1145507165723bba1e660aafb7f91de94fdd7ac33b5fd0fc681bccff692309c9d1545d2367424e8e58cf751
data/README.md CHANGED
@@ -45,17 +45,58 @@ You can also pass a query hash
45
45
  :FirstName => 'David',
46
46
  })
47
47
 
48
+ You can create contacts too
49
+
50
+ client = api_client.contact.create({
51
+ :FirstName => 'David',
52
+ :LastName => 'Lumley',
53
+ :Email => 'david@davidlumley.com.au',
54
+ :Company => 'Client Heartbeat',
55
+ })
56
+
57
+ You can also delete contacts by passing an ID
58
+
59
+ api_client.contact.delete(16)
60
+
61
+ Or by passing a query
62
+
63
+ api_client.contact.delete({
64
+ :FirstName => 'Trevor',
65
+ })
66
+
48
67
  #### Contact Groups
49
68
 
50
- Return a list of all contact groups (i.e. contacts with a tag or group)
51
- api_client.contact_group.all
69
+ Return a list of all contact groups
70
+ api_client.contact_group_assign.all
52
71
 
53
72
  You can also pass a hash query
54
73
 
55
- api_client.contact_group.all({
74
+ api_client.contact_group_assign.all({
75
+ :GroupCategoryId => 12,
76
+ })
77
+
78
+ #### Contact Group Assignments
79
+
80
+ Return a list of all contact group assignments (i.e. contacts with a tag or group)
81
+ api_client.contact_group_assign.all
82
+
83
+ You can also pass a hash query
84
+
85
+ api_client.contact_group_assign.all({
56
86
  :ContactGroup => 'New Customer',
57
87
  })
58
88
 
89
+ #### Contact Group Categories
90
+
91
+ Return a list of all contact group categories
92
+ api_client.contact_group_category.all
93
+
94
+ You can also pass a hash query
95
+
96
+ api_client.contact_group_category.all({
97
+ :CategoryName => 'Custom Tags',
98
+ })
99
+
59
100
  ## Todo
60
101
 
61
102
  * Expand API methods
@@ -10,6 +10,7 @@ module Infusionsoft
10
10
  def initialize(options)
11
11
  model :Contact
12
12
  model :ContactGroup
13
+ model :ContactGroupCategory
13
14
 
14
15
  @api_key = options[:api_key]
15
16
  @app_name = options[:app_name]
@@ -8,9 +8,26 @@ module Infusionsoft
8
8
  @model_name = model_name || 'Base'
9
9
  end
10
10
 
11
- def all(query = {}, page_number = 0)
11
+ def all(query = {}, paginate = true, page_number = 0)
12
12
  results = @client.connection.call('DataService.query', @client.api_key, self.table_name, 1000, page_number, query, self.fields)
13
- results.length > 0 ? results + self.all(query, page_number + 1) : results
13
+ results.length > 0 && paginate ? results + self.all(query, true, page_number + 1) : results
14
+ end
15
+
16
+ def first(query = {})
17
+ self.all(query, false)[0]
18
+ end
19
+
20
+ def create(data = {})
21
+ data['Id'] = @client.connection.call('DataService.add', @client.api_key, self.table_name, data)
22
+ data
23
+ end
24
+
25
+ def delete(query)
26
+ if query.is_a?(Hash)
27
+ self.all(query).each{|data| self.delete(data['Id'])}
28
+ else
29
+ @client.connection.call('DataService.delete', @client.api_key, self.table_name, query)
30
+ end
14
31
  end
15
32
 
16
33
  def table_name
@@ -3,24 +3,8 @@ module Infusionsoft
3
3
  module Model
4
4
  class ContactGroup < Infusionsoft::Api::Model::Base
5
5
 
6
- def all(query = {}, page_number = 0)
7
- results = super(query, page_number)
8
- results.map{|x|{
9
- 'Id' => x['ContactId'],
10
- 'FirstName' => x['Contact.FirstName'],
11
- 'LastName' => x['Contact.LastName'],
12
- 'Company' => x['Contact.Company'],
13
- 'Email' => x['Contact.Email'],
14
- 'ContactGroup' => x['ContactGroup'],
15
- }}
16
- end
17
-
18
- def table_name
19
- 'ContactGroupAssign'
20
- end
21
-
22
6
  def fields
23
- [:'ContactGroup', :'ContactId', :'Contact.FirstName', :'Contact.LastName', :'Contact.Company', :'Contact.Email']
7
+ [:'Id', :'GroupName', :'GroupCategoryId', :'GroupDescription']
24
8
  end
25
9
 
26
10
  end
@@ -0,0 +1,25 @@
1
+ module Infusionsoft
2
+ module Api
3
+ module Model
4
+ class ContactGroupAssign < Infusionsoft::Api::Model::Base
5
+
6
+ def all(query = {}, page_number = 0)
7
+ results = super(query, page_number)
8
+ results.map{|x|{
9
+ 'Id' => x['ContactId'],
10
+ 'FirstName' => x['Contact.FirstName'],
11
+ 'LastName' => x['Contact.LastName'],
12
+ 'Company' => x['Contact.Company'],
13
+ 'Email' => x['Contact.Email'],
14
+ 'ContactGroup' => x['ContactGroup'],
15
+ }}
16
+ end
17
+
18
+ def fields
19
+ [:'ContactGroup', :'ContactId', :'Contact.FirstName', :'Contact.LastName', :'Contact.Company', :'Contact.Email']
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ module Infusionsoft
2
+ module Api
3
+ module Model
4
+ class ContactGroupCategory < Infusionsoft::Api::Model::Base
5
+
6
+ def fields
7
+ [:Id, :CategoryName, :CategoryDescription]
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Infusionsoft
2
2
  module Api
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -5,5 +5,7 @@ require 'infusionsoft/api/helpers'
5
5
  require 'infusionsoft/api/models/base'
6
6
  require 'infusionsoft/api/models/contact'
7
7
  require 'infusionsoft/api/models/contact_group'
8
+ require 'infusionsoft/api/models/contact_group_assign'
9
+ require 'infusionsoft/api/models/contact_group_category'
8
10
 
9
11
  require 'infusionsoft/api/client'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infusionsoft-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - David Lumley
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,17 +27,15 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Infusionsoft API
@@ -62,36 +57,31 @@ files:
62
57
  - lib/infusionsoft/api/models/base.rb
63
58
  - lib/infusionsoft/api/models/contact.rb
64
59
  - lib/infusionsoft/api/models/contact_group.rb
60
+ - lib/infusionsoft/api/models/contact_group_assign.rb
61
+ - lib/infusionsoft/api/models/contact_group_category.rb
65
62
  - lib/infusionsoft/api/version.rb
66
63
  homepage: https://github.com/davidlumley/infusionsoft-api
67
64
  licenses:
68
65
  - MIT
66
+ metadata: {}
69
67
  post_install_message:
70
68
  rdoc_options: []
71
69
  require_paths:
72
70
  - lib
73
71
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
72
  requirements:
76
- - - ! '>='
73
+ - - '>='
77
74
  - !ruby/object:Gem::Version
78
75
  version: '0'
79
- segments:
80
- - 0
81
- hash: 2200985537662002865
82
76
  required_rubygems_version: !ruby/object:Gem::Requirement
83
- none: false
84
77
  requirements:
85
- - - ! '>='
78
+ - - '>='
86
79
  - !ruby/object:Gem::Version
87
80
  version: '0'
88
- segments:
89
- - 0
90
- hash: 2200985537662002865
91
81
  requirements: []
92
82
  rubyforge_project:
93
- rubygems_version: 1.8.23
83
+ rubygems_version: 2.0.3
94
84
  signing_key:
95
- specification_version: 3
85
+ specification_version: 4
96
86
  summary: Infusionsoft API
97
87
  test_files: []