birdseed 0.0.6 → 0.0.7
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 +4 -4
- data/README.md +4 -0
- data/lib/birdseed/version.rb +1 -1
- data/lib/birdseed.rb +10 -0
- data/spec/birdseed_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aad6351e60bd719e5658bd7eae7a74706ef03c7
|
4
|
+
data.tar.gz: 7ad49b0dfcc50cfc13e91691e51ccb2f06ddfd5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/birdseed/version.rb
CHANGED
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
|
data/spec/birdseed_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|