Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 1cdbd01
Author: ipolevoy <[email protected]>
Date:   Tue Sep 18 23:56:41 2018 -0500

    expresspigeon#22 Implement sending transactional messages with required and optional parameters

commit 4174115
Author: ipolevoy <[email protected]>
Date:   Tue Sep 18 23:56:31 2018 -0500

    expresspigeon#22 Implement sending transactional messages with required and optional parameters

commit 4ec9064
Author: ipolevoy <[email protected]>
Date:   Tue Sep 18 11:01:18 2018 -0500

    adding test to gitignore

commit ad30b5f
Merge: 7e15541 fc27903
Author: Igor Polevoy <[email protected]>
Date:   Mon Apr 30 08:47:27 2018 -0500

    Merge pull request expresspigeon#21 from Fooda/SNAP-2445-increase-read-timeout

    SNAP-2445: Increase Net::HTTP Read Timeout

commit 7e15541
Author: ipolevoy <[email protected]>
Date:   Mon Apr 30 08:07:33 2018 -0500

    small script mods

commit 6e309a5
Merge: 6bbde05 b41d26b
Author: Igor Polevoy <[email protected]>
Date:   Thu Jan 25 15:44:03 2018 -0700

    Merge pull request expresspigeon#20 from gsavvas/patch-1

    Fix misspelling in Readme

commit b41d26b
Author: Adam <[email protected]>
Date:   Thu Jan 25 16:38:13 2018 -0600

    Fix misspelling in Readme

commit 6bbde05
Author: Igor Polevoy <[email protected]>
Date:   Sat Apr 29 18:55:45 2017 -0500

    small script mods

commit 534a0b5
Author: Igor Polevoy <[email protected]>
Date:   Thu Apr 6 17:48:06 2017 -0500

    releasing 0.0.9

commit bd2e762
Author: Igor Polevoy <[email protected]>
Date:   Thu Apr 6 17:46:32 2017 -0500

    added headers argument

commit 63fd7b6
Author: Igor Polevoy <[email protected]>
Date:   Tue Feb 28 20:33:46 2017 -0600

    added some missing APIs

commit 3f4eee3
Author: Igor Polevoy <[email protected]>
Date:   Tue Feb 7 12:51:03 2017 -0600

    removed PIGEON const from specs

commit 517d823
Author: Igor Polevoy <[email protected]>
Date:   Wed Dec 14 15:50:47 2016 -0600

    merge fields need  to be sent as Json stirng instead of as individual parameters

commit ce2db27
Author: Igor Polevoy <[email protected]>
Date:   Tue Nov 22 00:20:58 2016 -0600

    copy

commit 5be3ca2
Author: Igor Polevoy <[email protected]>
Date:   Fri Nov 18 13:55:19 2016 -0600

    docs, typos

commit 350418c
Author: Igor Polevoy <[email protected]>
Date:   Fri Nov 18 13:49:37 2016 -0600

    expresspigeon#19 Implement sending messages with attachments - added address suppression argument

commit 79e5f22
Author: Igor Polevoy <[email protected]>
Date:   Tue Nov 8 15:02:06 2016 -0600

    expresspigeon#19 Implement sending messages with attachments
  • Loading branch information
agon-qurdina committed Jan 24, 2019
1 parent e1f8538 commit 350750d
Show file tree
Hide file tree
Showing 27 changed files with 620 additions and 179 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
.idea/


rspec.sh
scripts/*

set_env

*.txt

test/*

expresspigeon-ruby-*.gem
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.1.1
8 changes: 0 additions & 8 deletions .rvmrc

This file was deleted.

23 changes: 13 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
PATH
remote: .
specs:
expresspigeon-ruby (0.0.3)
rest-client (~> 1.8.0)
expresspigeon-ruby (0.1.1)
rest-client (~> 2.0.2)

GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
domain_name (0.5.24)
domain_name (0.5.20161021)
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.2)
http-cookie (1.0.3)
domain_name (~> 0.5)
mime-types (1.25.1)
netrc (0.7.9)
rest-client (1.8.0)
mime-types (2.99.3)
netrc (0.11.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
Expand All @@ -28,11 +28,14 @@ GEM
rspec-mocks (2.14.3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
unf_ext (0.0.7.2)

PLATFORMS
ruby

DEPENDENCIES
expresspigeon-ruby!
rspec (~> 2.6)

BUNDLED WITH
1.13.6
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Expresspigeon::Ruby

This is a Ruby library for convenince access to [ExpressPigeon API](https://expresspigeon.com/api).
This is a Ruby library for convenient access to [ExpressPigeon API](https://expresspigeon.com/api).

## Installation

Expand All @@ -16,11 +16,10 @@ Or install it yourself as:

$ gem install expresspigeon-ruby

## Usage
## Sending a simple message

Sending a transactional message is easy:


```ruby
MESSAGES = ExpressPigeon::API.messages.auth_key 'XXX'
message_response = MESSAGES.send_message 115, # template ID
Expand All @@ -40,6 +39,50 @@ sleep 5
puts MESSAGES.report message_response.id
```

## Sending a message with attachments

```ruby
MESSAGES = ExpressPigeon::API.messages.auth_key(ENV['AUTH_KEY'])

attachments = %W{attachments/attachment1.txt attachments/smile.pdf attachments/example.ics}

puts MESSAGES.send_message(
123, # template_id
'[email protected]', #to
'[email protected]', #reply_to
"Jane Doe", #from
"Want to get out for a dinner?", #subject
{first_name: 'John', main_course: 'stake'}, #merge_fields
false, #view_online
true, #click_tracking
true, #suppress_address
attachments #file paths to upload as attachments
)

```

## Sending a message with all required and optional arguments

```ruby

MESSAGES = ExpressPigeon::API.messages.auth_key(ENV['AUTH_KEY'])

attachments = %W{attachments/attachment1.txt attachments/calendar.ics}

puts MESSAGES.send_msg 123, '[email protected]', '[email protected]',
'Jane Doe', 'A simple test subject',
merge_fields: { first_name: "John" },
view_online: false,
click_tracking: true,
suppress_address: false,
attachments: attachments,
headers: { Xtest: "test" },
reply_name: "Jane S. Doe",
from_address: "[email protected]"

```

The first five arguments are mandatory, while the rest are optional.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions expresspigeon-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_runtime_dependency 'rest-client', '~> 1.8.0'

gem.add_runtime_dependency 'rest-client', '~> 2.0.2'
gem.add_development_dependency "rspec", "~> 2.6"
gem.licenses = ['MIT']
end
19 changes: 13 additions & 6 deletions lib/expresspigeon-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
module ExpressPigeon

AUTH_KEY = ENV['EXPRESSPIGEON_AUTH_KEY']
ROOT = 'https://api.expresspigeon.com/'

# EXPRESSPIGEON_ROOT env var is used to point to testenv
ROOT = ENV.has_key?('EXPRESSPIGEON_ROOT') ? ENV['EXPRESSPIGEON_ROOT'] : 'https://api.expresspigeon.com/'
USE_SSL = true

module API
Expand Down Expand Up @@ -76,11 +78,16 @@ def http(path, method, params = {})
) do |http|
http.request req
end
parsed = JSON.parse(resp.body)
if parsed.kind_of? Hash
MetaResponse.new parsed

if resp.content_type == 'application/json'
parsed = JSON.parse(resp.body)
if parsed.kind_of? Hash
MetaResponse.new parsed
else
parsed
end
else
parsed
resp.body
end
end
end
Expand Down Expand Up @@ -121,7 +128,7 @@ def self.messages
Messages.new
end

def self.auto_responders
def self.autoresponders
AutoResponders.new
end

Expand Down
47 changes: 41 additions & 6 deletions lib/expresspigeon-ruby/auto_responders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def initialize
#
# Returns an array of autoresponders.
#
# Docs: https://expresspigeon.com/api#auto_responders_get_all
#
def all
get endpoint
get @endpoint
end

# Start for a contact
Expand All @@ -25,10 +23,9 @@ def all
# :param auto_responder_id: autoresponder id to be started for a contact
# :param email: contact email
#
# Docs: https://expresspigeon.com/api#auto_responders_start
#
def start(auto_responder_id, email)
post "#{endpoint}/#{auto_responder_id}/start", email: email
post "#{@endpoint}/#{auto_responder_id}/start", email: email
end

# Stop for a contact
Expand All @@ -41,7 +38,45 @@ def start(auto_responder_id, email)
# Docs: https://expresspigeon.com/api#auto_responders_stop
#
def stop(auto_responder_id, email)
post "#{endpoint}/#{auto_responder_id}/stop", email: email
post "#{@endpoint}/#{auto_responder_id}/stop", email: email
end

# Reports for a single responder
#
# :param auto_responder_id: autoresponder id to be stopped for a contact
# :param email: contact email
#
def report(auto_responder_id)
get "#{@endpoint}/#{auto_responder_id}"
end


# Reports bounces for autoresponder part
#
# :param auto_responder_id: autoresponder id to be stopped for a contact
# :param auto_responder_part_id: id of the autoresponder part in questions
#
def bounced(auto_responder_id, autoresponder_part_id)
get "#{@endpoint}/#{auto_responder_id}/#{autoresponder_part_id}/bounced"
end

# Reports unsubscribed for autoresponder part
#
# :param auto_responder_id: autoresponder id to be stopped for a contact
# :param auto_responder_part_id: id of the autoresponder part in questions
#
def unsubscribed(auto_responder_id, autoresponder_part_id)
get "#{@endpoint}/#{auto_responder_id}/#{autoresponder_part_id}/unsubscribed"
end


# Get spam reports for autoresponder part
#
# :param auto_responder_id: autoresponder id to be stopped for a contact
# :param auto_responder_part_id: id of the autoresponder part in questions
#
def spam(auto_responder_id, autoresponder_part_id)
get "#{@endpoint}/#{auto_responder_id}/#{autoresponder_part_id}/spam"
end
end
end
8 changes: 8 additions & 0 deletions lib/expresspigeon-ruby/campaigns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def report(campaign_id)
get "#{@endpoint}/#{campaign_id}"
end

def opened(campaign_id)
get "#{@endpoint}/#{campaign_id}/opened"
end

def clicked(campaign_id)
get "#{@endpoint}/#{campaign_id}/clicked"
end

def bounced(campaign_id)
get "#{@endpoint}/#{campaign_id}/bounced"
end
Expand Down
1 change: 1 addition & 0 deletions lib/expresspigeon-ruby/contacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def find_by_email(email)
end



# JSON document represents a contact to be created or updated.
# The email field is required.
# When updating a contact, list_id is optional,
Expand Down
7 changes: 7 additions & 0 deletions lib/expresspigeon-ruby/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def update(list_id, params = {})
end


#
#:returns: status of upload
#
def upload_status(list_id)
get "#{@endpoint}/upload_status/#{list_id}"
end

##
# Removes a list with a given id. A list must be enabled and has no dependent subscriptions and/or scheduled campaigns.
#
Expand Down
Loading

0 comments on commit 350750d

Please sign in to comment.