birdseed 0.0.8 → 0.0.9
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/.ruby-version +1 -1
- data/README.md +10 -1
- data/lib/birdseed.rb +15 -0
- data/lib/birdseed/version.rb +1 -1
- data/spec/birdseed_spec.rb +11 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 096e586d78c80b82c05c1439c5c29391c04cc56b
|
4
|
+
data.tar.gz: 42c25b4183fc66459eaba7d092f6cea37636afe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2df10214af1efceae357a236fd161eb8f817f733944ac61d7075bb5c4b617fe323081afcadaaba570657c5f3bd650b1ad755a2764f3cd6b302525b3a7a11332f
|
7
|
+
data.tar.gz: 7833a54f76842a1a08f2a3c6c7e342bf8e20f1f0f8989b0ce49a9965b59cd24158ad833c5aaaa94338867a38a52e89bee9fd7591b5e06f307449634533fc97ea
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Or install it yourself as:
|
|
19
19
|
## Usage
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
# Delivers
|
22
|
+
# Delivers a Delivery.
|
23
23
|
Birdseed.api_key = "YOUR_API_KEY"
|
24
24
|
Birdseed.deliver(
|
25
25
|
campaign_id: "some_campaign_id",
|
@@ -27,6 +27,15 @@ Or install it yourself as:
|
|
27
27
|
data: {some: "data"}
|
28
28
|
)
|
29
29
|
|
30
|
+
# Delivers a DeliveryItem.
|
31
|
+
Birdseed.api_key = "YOUR_API_KEY"
|
32
|
+
Birdseed.deliver_item(
|
33
|
+
campaign_id: "some_campaign_id",
|
34
|
+
scope: "1",
|
35
|
+
recipient: {address: "nic@edmodo.com", name: "Nic"},
|
36
|
+
data: {some: "data"}
|
37
|
+
)
|
38
|
+
|
30
39
|
# Finds sample data for a campaign.
|
31
40
|
Birdseed.sample_data('some_campaign_id', default_value: 'DEFAULT_VALUE')
|
32
41
|
```
|
data/lib/birdseed.rb
CHANGED
@@ -36,6 +36,21 @@ module Birdseed
|
|
36
36
|
Hashie::Mash.new(JSON.parse(response))
|
37
37
|
end
|
38
38
|
|
39
|
+
# See https://github.com/edmodo/fatbird#send-emails-using-rest-api
|
40
|
+
def self.deliver_item(options={})
|
41
|
+
api_key = options.delete(:api_key) || @@api_key
|
42
|
+
|
43
|
+
response = RestClient::Request.execute(
|
44
|
+
method: :post,
|
45
|
+
url: "#{self.fatbird_host}/delivery_items",
|
46
|
+
payload: JSON.generate(options),
|
47
|
+
headers: {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json},
|
48
|
+
timeout: REQUEST_TIMEOUT,
|
49
|
+
open_timeout: OPEN_TIMEOUT
|
50
|
+
)
|
51
|
+
Hashie::Mash.new(JSON.parse(response))
|
52
|
+
end
|
53
|
+
|
39
54
|
def self.sample_data(campaign_id, options={})
|
40
55
|
api_key = options.delete(:api_key) || @@api_key
|
41
56
|
default_value = options[:default_value] || 'VALUE'
|
data/lib/birdseed/version.rb
CHANGED
data/spec/birdseed_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'birdseed'
|
|
4
4
|
describe Birdseed do
|
5
5
|
let(:response) { double('Response') }
|
6
6
|
|
7
|
-
it "should send
|
7
|
+
it "should send delivery" do
|
8
8
|
Birdseed.api_key = "test_api_key"
|
9
9
|
stub_request(:post, "#{Birdseed.fatbird_host}/deliveries").
|
10
10
|
with(:body => JSON.generate({template_id: 'test_template', recipient: {address: 'test@example.com'}}),
|
@@ -14,6 +14,16 @@ describe Birdseed do
|
|
14
14
|
expect(result.id).to eq(10956571)
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should send delivery item" do
|
18
|
+
Birdseed.api_key = "test_api_key"
|
19
|
+
stub_request(:post, "#{Birdseed.fatbird_host}/delivery_items").
|
20
|
+
with(:body => JSON.generate({campaign_id: 'fatbird-test', scope: "1", recipient: {address: 'test@example.com'}}),
|
21
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'api_key test_api_key', 'Content-Type'=>'application/json'}).
|
22
|
+
to_return(:status => 200, :body => "{\"url\":\"https://fatbird.edmodo.com/delivery_items/10956571\",\"campaign_id\":\"fatbird-test\",\"scope\":\"1\",\"recipient\":{\"address\":\"jerry@edmodo.com\",\"name\":\"Jerry Luk\"},\"locale\":\"en-US\",\"id\":10956571,\"send_at\":null,\"sent_at\":null,\"data\":null,\"created_at\":\"2015-04-21T22:36:28.786Z\",\"updated_at\":\"2015-04-21T22:36:28.786Z\"}", :headers => {})
|
23
|
+
result = Birdseed.deliver_item(campaign_id: 'fatbird-test', scope: "1", recipient: {address: 'test@example.com'})
|
24
|
+
expect(result.id).to eq(10956571)
|
25
|
+
end
|
26
|
+
|
17
27
|
it "should get sample data" do
|
18
28
|
Birdseed.api_key = "test_api_key"
|
19
29
|
stub_request(:get, "#{Birdseed.fatbird_host}/campaigns/test/sample_data?dafault_value=DEFAULT_VALUE").
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry Luk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.5.1
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Send emails with FatBird
|