active_campaign 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb45bc281708e6be460d3e33379cd2c74c26d737
4
- data.tar.gz: 12b0835d724fd3e093e1ffd0cf78db46cbc03a8f
3
+ metadata.gz: 8374196fd92155a286e77b4fe506b6501d9139c9
4
+ data.tar.gz: ec32eb1ed1f4a16715aeab31a79f9185eda64820
5
5
  SHA512:
6
- metadata.gz: e5f30055cd574ede7437056b3dde2cca94043a45a06033e13af3f478e91bd42e47629be65bc62d298c4ceb42eaec1837f985e423e9a1f095bf2e4edc0f018517
7
- data.tar.gz: 77b9c9106c0fd0bba33cb1eb626a293cf131d5d54d82be44d42a2ad7bcde54316222cc6aa48bb29c8cae4899852ed342a0960bd8bf504889f09eab4ac7e470e6
6
+ metadata.gz: 08fcb77345cb64d5de8b86387e29f592c6135d41cc0b4ab47528ec3811a5a8ba88685005f0b856766275c850c45d0ea3ee2abbe9a0ea5be4f95bc809179fcc9a
7
+ data.tar.gz: 48be9985590a1604bc00ef3817153bb5a8b98131e6851b5d4e665bc67811c8184cd1482045b5550ad3b4f1cc22b8fd6f36d8dfbeedd73f2e179e6068ef9cfa9b
data/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  # Active::Campaign::Ruby
2
2
 
3
- TODO: Write a gem description
3
+ A simple wrapper for the ActiveCampaign API. Since their API seems to be
4
+ basically just form posts to their server don't complain here about the way it
5
+ works. The only thing we really changed was how results are wrapped and
6
+ returned and you can read more about that here.
4
7
 
5
8
  ## Installation
6
9
 
7
10
  Add this line to your application's Gemfile:
8
11
 
9
- gem 'active-campaign'
12
+ gem 'active_campaign'
10
13
 
11
14
  And then execute:
12
15
 
@@ -14,16 +17,89 @@ And then execute:
14
17
 
15
18
  Or install it yourself as:
16
19
 
17
- $ gem install active-campaign
20
+ $ gem install active_campaign
18
21
 
19
22
  ## Usage
20
23
 
21
- TODO: Write usage instructions here
24
+ Read their [API documentation](http://www.activecampaign.com/api/overview.php)for how to use this gem.
25
+
26
+ ```ruby
27
+ # To fetch all lists
28
+ ActiveCampaign.list_list ids: 'all'
29
+ ```
30
+
31
+ ```ruby
32
+ # To sync a contact (create if doesn't exist or update if matching email)
33
+ # you have to resort to some really ugly hacks. Due to the form serialization # type of API (read not a object oriented REST API) you need to translate
34
+ # something pretty into something horrific when it comes to the parameters.
35
+ ActiveCampaign.contact_sync({
36
+ "id" => user.active_campaign_contact_id,
37
+ "email" => user.email,
38
+ "first_name" => user.first,
39
+ "last_name" => user.last,
40
+ "p[#{user.active_campaign_list_id}]" => user.active_campaign_list_id,
41
+ "status[#{user.active_campaign_list_id}" => user.receive_emails ? 1 : 2
42
+ })
43
+
44
+ # Another example of syncing a contact:
45
+
46
+ list_params = {
47
+ "#{user.active_campaign_list_id}" => user.active_campaign_list_id,
48
+ "#{user.other_list_id}" => user.other_list_id,
49
+ }
50
+
51
+ status_params = {
52
+ "#{user.active_campaign_list_id}" => user.receive_emails ? 1 : 2,
53
+ "#{user.other_list_id}" => true ? 1 : 2,
54
+ }
55
+
56
+ ActiveCampaign.contact_sync({
57
+ "id" => user.active_campaign_contact_id,
58
+ "email" => user.email,
59
+ "first_name" => user.first,
60
+ "last_name" => user.last,
61
+ "p" => list_params
62
+ "status" => status_params
63
+ })
64
+ ```
65
+
66
+ ## Response
67
+
68
+ All responses are wrapped under `results` so
69
+ `ActiveCampaign.list_list ids: 'all'` returns
70
+
71
+ ```ruby
72
+ {
73
+ "result_code" => 1,
74
+ "result_message" => "Success: Something is returned",
75
+ "result_output" => "json",
76
+ "results" => [
77
+ {
78
+ "id" => "1",
79
+ "name" => "One list",
80
+ "cdate" => "2013-05-22 10:07:36",
81
+ "private" => "0",
82
+ "userid" => "1",
83
+ "subscriber_count" => 2
84
+ },
85
+ {
86
+ "id" => "2",
87
+ "name" => "Another List",
88
+ "cdate" => "2013-05-22 10:09:15",
89
+ "private" => "0",
90
+ "userid" => "1",
91
+ "subscriber_count" => 0
92
+ }
93
+ ]
94
+ }
95
+ ```
96
+
22
97
 
23
98
  ## Contributing
24
99
 
25
100
  1. Fork it
26
101
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
102
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
103
+ 4. Rebase against master we want 1 commit per feature please
104
+ 5. Push to the branch (`git push origin my-new-feature`)
105
+ 6. Create new Pull Request
@@ -19,7 +19,6 @@ module ActiveCampaign
19
19
  request(:post, api_method, options).body
20
20
  rescue => e
21
21
  puts e, e.backtrace
22
- binding.pry
23
22
  end
24
23
 
25
24
  def put(api_method, options={})
@@ -1,3 +1,3 @@
1
1
  module ActiveCampaign
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -6,7 +6,7 @@ require 'active_campaign/error'
6
6
  require 'active_campaign/client'
7
7
 
8
8
 
9
- require "pry"
9
+ require "pry" rescue nil
10
10
 
11
11
  module ActiveCampaign
12
12
 
@@ -41,7 +41,6 @@ describe ActiveCampaign::Client::Lists do
41
41
  # to_return json_response("list_view.json")
42
42
 
43
43
  lists = @client.list_list "ids" => 'all'
44
- binding.pry
45
44
  expect(lists.results[0].name).to eq "Swedish Players"
46
45
  end
47
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_campaign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-28 00:00:00.000000000 Z
11
+ date: 2013-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient