expresspigeon-ruby 0.0.1 → 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 219e88febc4f6de2dec7d8688366a8ad687b8928
4
+ data.tar.gz: a060f8c93df2f5dc6329ea4b098eed97da24e310
5
+ SHA512:
6
+ metadata.gz: d24f13e62161c083a61437e14474f24552c37d64606e23adc3c0d0016837e08f004296af4ac1230f54bad9c0a1f85fe7415c9b19484823980417d122a7d75913
7
+ data.tar.gz: 84e93e5168cbfc8df275cc564e9b2b72feebc413a238a06b314f16de037530848c88b7de577a8a0ddacd70a4b6b6be6c2badc0f60a0c204f8552fe130c0ff094
data/.gitignore CHANGED
@@ -1,19 +1,7 @@
1
- *.rbc
2
- *.sassc
3
- .sass-cache
4
- capybara-*.html
5
- .rspec
6
- /.bundle
7
- /vendor/bundle
8
- /log/*
9
- /tmp/*
10
- /db/*.sqlite3
11
- /public/system/*
12
- /coverage/
13
- /spec/tmp/*
14
- **.orig
15
- rerun.txt
16
- pickle-email-*.html
17
- doc/structures.csv
1
+
18
2
  *.iml
19
3
  .idea/
4
+
5
+
6
+ rspec.sh
7
+ set_env
data/.rvmrc CHANGED
@@ -3,6 +3,6 @@ USER_RVMRC='.rvmrc.local'
3
3
  if [ -f $USER_RVMRC ]; then
4
4
  source $USER_RVMRC
5
5
  else
6
- rvm use 1.9.3@expresspigeon-ruby --create
6
+ rvm use 2.1.5 --create
7
7
  fi
8
8
 
data/README.md CHANGED
@@ -18,7 +18,26 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Sending a transactional message is easy:
22
+
23
+
24
+ ```ruby
25
+ MESSAGES = ExpressPigeon::API.messages.auth_key 'XXX'
26
+ message_response = MESSAGES.send_message 115, # template ID
27
+ 'to_john@doe.com', # send to
28
+ 'from_jane@doe.com', # reply to
29
+ "Jane Dow", # senders name
30
+ 'Hi there!', # subject
31
+ # hash with custom content to merge
32
+ content: "hello, there!"
33
+
34
+ puts message_response
35
+
36
+ # need to wait before message information is written to DB
37
+ sleep 5
38
+
39
+ # get a report for a specific message
40
+ puts MESSAGES.report message_response.id
22
41
 
23
42
  ## Contributing
24
43
 
@@ -4,21 +4,34 @@ require 'net/http'
4
4
  require 'json'
5
5
  require 'uri'
6
6
 
7
- AUTH_KEY = ENV['EXPRESSPIGEON_AUTH_KEY']
8
- ROOT = 'https://api.expresspigeon.com/'
9
- #ROOT = 'http://localhost:8888/api/'
10
- USE_SSL = true
11
-
12
7
  module ExpressPigeon
8
+
9
+ AUTH_KEY = ENV['EXPRESSPIGEON_AUTH_KEY']
10
+ ROOT = 'https://api.expresspigeon.com/'
11
+ USE_SSL = true
12
+
13
13
  module API
14
- unless AUTH_KEY
15
- raise 'Provide EXPRESSPIGEON_AUTH_KEY environment variable'
14
+
15
+ # Override environment variable in code.
16
+ def auth_key(auth_key)
17
+ @auth_key = auth_key
18
+ self
19
+ end
20
+
21
+ def root(root)
22
+ @root = root
23
+ self
16
24
  end
17
25
 
18
26
  def http(path, method, params = {})
19
- uri = URI.parse "#{ROOT}#{path}"
27
+ root = @root ? @root : ROOT
28
+ uri = URI.parse "#{root}#{path}"
20
29
  req = Net::HTTP.const_get("#{method}").new "#{ROOT}#{path}"
21
- req['X-auth-key'] = AUTH_KEY
30
+ unless AUTH_KEY || @auth_key
31
+ raise("Must set either EXPRESSPIGEON_AUTH_KEY as environment variable, or ExpressPigeon::AUTH_KEY in code")
32
+ end
33
+
34
+ req['X-auth-key'] = AUTH_KEY ? AUTH_KEY : @auth_key
22
35
  if params
23
36
  req.body = params.to_json
24
37
  req['Content-type'] = 'application/json'
@@ -302,5 +315,4 @@ class Messages
302
315
  get query
303
316
 
304
317
  end
305
-
306
318
  end
@@ -1,5 +1,5 @@
1
1
  module Expresspigeon
2
2
  module API
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/spec/lists_spec.rb CHANGED
@@ -3,10 +3,14 @@ require 'pigeon_helper'
3
3
 
4
4
  describe 'contacts integration test' do
5
5
 
6
+ LISTS = ExpressPigeon::API.lists #.auth_key('f5bfd636-6219-46f9-ae05-de1fc841b464')
7
+
8
+ ExpressPigeon::ROOT = 'https://api.expresspigeontest.com/'
9
+
6
10
  include PigeonSpecHelper
7
11
 
8
12
  it 'test_create_and_delete_new_list(self):' do
9
- contact_list = PIGEON.lists.create 'Active customers', 'Bob', 'bob@acmetools.com'
13
+ contact_list = LISTS.create 'Active customers', 'Bob', 'bob@acmetools.com'
10
14
 
11
15
  puts "*****************************"
12
16
  puts contact_list
@@ -25,14 +29,18 @@ describe 'contacts integration test' do
25
29
  #contact_list.list.country.should eq "Belarus"
26
30
  #contact_list.list.organization.should eq "ExpressPigeon"
27
31
 
28
- res = PIGEON.lists.delete(contact_list.list.id)
32
+ res = LISTS.delete(contact_list.list.id)
33
+
34
+ puts res
35
+
29
36
  validate_response res, 200, 'success', /list=#{contact_list.list.id} deleted successfully/
30
37
  end
31
38
 
32
39
  #TODO: implement Lists.update method
33
40
  it 'should update existing list' do
34
41
 
35
- existing_list = PIGEON.lists.create("Update", "Bob", "bob@acmetools.com")
42
+ existing_list = LISTS.create("Update", "Bob", "bob@acmetools.com")
43
+ LISTS.delete(existing_list.list.id)
36
44
  #res = PIGEON.lists.update existing_list.list.id, :name => 'Updated Name', :from_name => 'Bill'
37
45
  #
38
46
  #validate_response res, 200, 'success', /list=#{res.list.id} created\/updated successfully/
@@ -45,7 +53,10 @@ describe 'contacts integration test' do
45
53
  it 'should upload contacts'
46
54
 
47
55
  list_name = "Upload_#{Kernel.rand(9999).to_s}"
48
- existing_list = PIGEON.lists.create(list_name, 'Bob', 'bob@acmetools.com')
56
+ existing_list = LISTS.create(list_name, 'Bob', 'bob@acmetools.com')
57
+
58
+ puts existing_list
59
+ res = LISTS.delete(existing_list.list.id)
49
60
 
50
61
  #res = PIGEON.lists.upload(existing_list.list.id, self.file_to_upload)
51
62
 
@@ -32,7 +32,7 @@ describe 'transactional messages integration test' do
32
32
 
33
33
  #TODO: complete the spec
34
34
  it 'sends a single transactional message' do
35
- message_response = PIGEON.messages.send_message 4905, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'], "Team ExpressPigeon", "Hi there!",
35
+ message_response = PIGEON.messages.send_message 115, ENV['TARGET_EMAIL'], ENV['TARGET_EMAIL'], "Team ExpressPigeon", "Hi there!",
36
36
  :first_name => "Igor"
37
37
  validate_response message_response, 200, 'success', /email queued/
38
38
  report = PIGEON.messages.report(message_response.id)
@@ -1,4 +1,4 @@
1
- PIGEON ||= ExpressPigeon::API
1
+
2
2
  TEMPLATE_ID ||= 1
3
3
  LIST_ID ||= 12
4
4
  API_USER ||= "non@non.non"
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expresspigeon-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - ipolevoy
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.6'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '2.6'
30
27
  description: ExpressPigeon Ruby API for sending transactional messages, manipulating
@@ -35,8 +32,8 @@ executables: []
35
32
  extensions: []
36
33
  extra_rdoc_files: []
37
34
  files:
38
- - .gitignore
39
- - .rvmrc
35
+ - ".gitignore"
36
+ - ".rvmrc"
40
37
  - Gemfile
41
38
  - Gemfile.lock
42
39
  - LICENSE.txt
@@ -52,27 +49,26 @@ files:
52
49
  - spec/pigeon_helper.rb
53
50
  homepage: https://github.com/expresspigeon/expresspigeon-ruby
54
51
  licenses: []
52
+ metadata: {}
55
53
  post_install_message:
56
54
  rdoc_options: []
57
55
  require_paths:
58
56
  - lib
59
57
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
58
  requirements:
62
- - - ! '>='
59
+ - - ">="
63
60
  - !ruby/object:Gem::Version
64
61
  version: '0'
65
62
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
63
  requirements:
68
- - - ! '>='
64
+ - - ">="
69
65
  - !ruby/object:Gem::Version
70
66
  version: '0'
71
67
  requirements: []
72
68
  rubyforge_project:
73
- rubygems_version: 1.8.25
69
+ rubygems_version: 2.4.3
74
70
  signing_key:
75
- specification_version: 3
71
+ specification_version: 4
76
72
  summary: ExpressPigeon API Ruby Wrapper
77
73
  test_files:
78
74
  - spec/campaigns_spec.rb