birdseed 0.0.6 → 0.0.7

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: 256d33722af8800d0a0f217cb568156328a8eb94
4
- data.tar.gz: 7b395c09459357a960fffb4c778e909d9982c5af
3
+ metadata.gz: 6aad6351e60bd719e5658bd7eae7a74706ef03c7
4
+ data.tar.gz: 7ad49b0dfcc50cfc13e91691e51ccb2f06ddfd5a
5
5
  SHA512:
6
- metadata.gz: 4624f624107c18775aa0eebaed37d59993b4b5ece8f89409c69cea5d29332a99c5f8ab0d83e10e008530db4d6a5338a8bd75ab2db3250cb61c2c8a11b3064ca9
7
- data.tar.gz: e1b57a29ea2d5ba028d4cd4ea35654637bb9bec23231cf98231498d0d8dd63d1fbfb264544e1aa1254e4dad8e001114ad234bf64917796608ee0dc5539df2553
6
+ metadata.gz: 7832ed4376023e245b2a9505bfd00c13b34adb24981c15a05b75e4b1322a9a40564cc0e3383916b50b52588e92fc8bfc03b728af4c10e2db9c76ebc9431840ea
7
+ data.tar.gz: f605d07d3a29b752723c1f1108493c68144532895050571eaa60fbac93acc4157e6c9e94c07335626f44dafa727bc25978e96d4e8631fbc2664ef9c3e0818017
data/README.md CHANGED
@@ -19,12 +19,16 @@ Or install it yourself as:
19
19
  ## Usage
20
20
 
21
21
  ```ruby
22
+ # Delivers an Email.
22
23
  Birdseed.api_key = "YOUR_API_KEY"
23
24
  Birdseed.deliver(
24
25
  campaign_id: "some_campaign_id",
25
26
  recipient: {address: "nic@edmodo.com", name: "Nic"},
26
27
  data: {some: "data"}
27
28
  )
29
+
30
+ # Finds sample data for a campaign.
31
+ Birdseed.sample_data('some_campaign_id', default_value: 'DEFAULT_VALUE')
28
32
  ```
29
33
 
30
34
  See all options at https://github.com/edmodo/fatbird#send-emails-using-rest-api
@@ -1,3 +1,3 @@
1
1
  module Birdseed
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/birdseed.rb CHANGED
@@ -30,4 +30,14 @@ module Birdseed
30
30
  Hashie::Mash.new(JSON.parse(response))
31
31
  end
32
32
 
33
+ def self.sample_data(campaign_id, options={})
34
+ api_key = options.delete(:api_key) || @@api_key
35
+ default_value = options[:default_value] || 'VALUE'
36
+ response = RestClient.get(
37
+ "#{self.fatbird_host}/campaigns/#{campaign_id}/sample_data?dafault_value=#{default_value}",
38
+ {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json}
39
+ )
40
+ JSON.parse(response)
41
+ end
42
+
33
43
  end
@@ -13,4 +13,13 @@ describe Birdseed do
13
13
  result = Birdseed.deliver(template_id: 'test_template', recipient: {address: 'test@example.com'})
14
14
  expect(result.id).to eq(10956571)
15
15
  end
16
+
17
+ it "should get sample data" do
18
+ Birdseed.api_key = "test_api_key"
19
+ stub_request(:get, "#{Birdseed.fatbird_host}/campaigns/test/sample_data?dafault_value=DEFAULT_VALUE").
20
+ with(:headers => {'Accept'=>'application/json', 'Authorization'=>'api_key test_api_key', 'Content-Type'=>'application/json'}).
21
+ to_return(:status => 200, :body => JSON.generate("test" => "VALUE"), :headers => {})
22
+ result = Birdseed.sample_data('test', default_value: 'DEFAULT_VALUE')
23
+ expect(result).to eq({"test" => "VALUE"})
24
+ end
16
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birdseed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Luk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-22 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler