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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da2dc140437b3695cf6285cdaa1d87d29c88c232
4
- data.tar.gz: e607318764bbcf00ad44df6a157615852f910e88
3
+ metadata.gz: 096e586d78c80b82c05c1439c5c29391c04cc56b
4
+ data.tar.gz: 42c25b4183fc66459eaba7d092f6cea37636afe7
5
5
  SHA512:
6
- metadata.gz: 6d4b280c7cf0a9a95804630f3c0707bea72c6339aebf28a37d10cbe8324a3bc93cecff0ea73d27ab0069e2496317a9f0e68dac5c5dd1e5d8afdbed87927c24b0
7
- data.tar.gz: 309a7560fce35cc36af29bdf5320678adae258243914a6e263ae9ca0a5891dde1ca8d59950b31ad2e94cbcbeb965e70f748aaab28bf9c6c0259c8c642e967e79
6
+ metadata.gz: 2df10214af1efceae357a236fd161eb8f817f733944ac61d7075bb5c4b617fe323081afcadaaba570657c5f3bd650b1ad755a2764f3cd6b302525b3a7a11332f
7
+ data.tar.gz: 7833a54f76842a1a08f2a3c6c7e342bf8e20f1f0f8989b0ce49a9965b59cd24158ad833c5aaaa94338867a38a52e89bee9fd7591b5e06f307449634533fc97ea
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.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 an Email.
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'
@@ -1,3 +1,3 @@
1
1
  module Birdseed
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -4,7 +4,7 @@ require 'birdseed'
4
4
  describe Birdseed do
5
5
  let(:response) { double('Response') }
6
6
 
7
- it "should send email" do
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.8
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: 2015-08-25 00:00:00.000000000 Z
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.4.6
151
+ rubygems_version: 2.5.1
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Send emails with FatBird