infusionsoft-api 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ module Infusionsoft
7
7
  results = super(query, paginate, page_number)
8
8
  results.map{|x|{
9
9
  'Id' => x['ContactId'],
10
+ 'GroupId' => x['GroupId'],
10
11
  'FirstName' => x['Contact.FirstName'],
11
12
  'LastName' => x['Contact.LastName'],
12
13
  'Company' => x['Contact.Company'],
@@ -15,8 +16,37 @@ module Infusionsoft
15
16
  }}
16
17
  end
17
18
 
19
+ def create(data = {})
20
+ data = standardise_query(data)
21
+ @client.connection.call('ContactService.addToGroup', @client.api_key, data[:ContactId], data[:GroupId])
22
+ end
23
+
24
+ def delete(query = {})
25
+ query = standardise_query(query)
26
+ if query[:ContactId] && query[:GroupId]
27
+ @client.connection.call('ContactService.removeFromGroup', @client.api_key, query[:ContactId], query[:GroupId])
28
+ else
29
+ self.all(query).each do |data|
30
+ self.delete({
31
+ :ContactId => data['Id'],
32
+ :GroupId => data['GroupId'],
33
+ })
34
+ end
35
+ end
36
+ end
37
+
18
38
  def fields
19
- [:'ContactGroup', :'ContactId', :'Contact.FirstName', :'Contact.LastName', :'Contact.Company', :'Contact.Email']
39
+ [:'ContactGroup', :'ContactId', :'GroupId', :'Contact.FirstName', :'Contact.LastName', :'Contact.Company', :'Contact.Email']
40
+ end
41
+
42
+ private
43
+
44
+ def standardise_query(query = {})
45
+ if query['ContactId'] && query['GroupId']
46
+ query[:ContactId] = query['ContactId']
47
+ query[:GroupId] = query['GroupId']
48
+ end
49
+ query
20
50
  end
21
51
 
22
52
  end
@@ -1,5 +1,5 @@
1
1
  module Infusionsoft
2
2
  module Api
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infusionsoft-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -80,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  segments:
82
82
  - 0
83
- hash: 3226072949163363730
83
+ hash: 3644684358568628109
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: 3226072949163363730
92
+ hash: 3644684358568628109
93
93
  requirements: []
94
94
  rubyforge_project:
95
95
  rubygems_version: 1.8.23