pepipost 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/lib/pepipost.rb +22 -0
- data/lib/pepipost/api_exception.rb +19 -0
- data/lib/pepipost/api_helper.rb +74 -0
- data/lib/pepipost/configuration.rb +12 -0
- data/lib/pepipost/controllers/email_controller.rb +111 -0
- data/lib/pepipost/models/attributes.rb +29 -0
- data/lib/pepipost/models/email_details.rb +49 -0
- data/lib/pepipost/models/emailv_1.rb +54 -0
- data/lib/pepipost/models/files.rb +24 -0
- data/lib/pepipost/models/settings.rb +61 -0
- data/lib/pepipost/pepipost_client.rb +13 -0
- data/lib/pepipost/version.rb +3 -0
- data/pepipost.gemspec +25 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 948c51fd6ab938dbc89aa02872b74b5d39cbc6c9
|
4
|
+
data.tar.gz: 57d7fbe4e46108ce3ccd98433035bf914b504eb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd69de2daca7f99848f02c0f5b5338541669fb7162c87c98754436dc509e047ac4df87b5cf16d1a36f8feff4c67af3742f9bc3a160e6e114ec59bfb3fd2582df
|
7
|
+
data.tar.gz: f6c7a1deb6f363ce3d375ce11599d81ddf9255958558a226c4f3434d62ef9cffe3ac59dda66e6263d68a9a9a90393c5158325c1dd20639cccc36b686ce97516d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rake'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Mikhail Mandronov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Pepipost
|
2
|
+
|
3
|
+
Ruby gem for Pepipost service, wrapper of pepipost sdk:
|
4
|
+
https://github.com/pepipost/pepipost-sdk-ruby
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'pepipost'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install pepipost
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
require 'pepipost'
|
25
|
+
|
26
|
+
data = {
|
27
|
+
"api_key"=>"yoursecretapikey",
|
28
|
+
"recipients"=> ["recipient1@example.com","recipient2@example.com"],
|
29
|
+
"email_details" => {
|
30
|
+
"fromname" => "sender name",
|
31
|
+
"subject" => "This is a test email sent usig Pepipost SDK for Ruby",
|
32
|
+
"from" => "from@example.com",
|
33
|
+
"content" => "<p>This is a test email sent using Pepipost SDK for Ruby</p>",
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
email = Pepipost::Email.new
|
39
|
+
response = email.send data
|
40
|
+
|
41
|
+
print response
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/pepipost/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/pepipost.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "pepipost/version"
|
2
|
+
|
3
|
+
require 'openssl'
|
4
|
+
require 'json'
|
5
|
+
require 'unirest'
|
6
|
+
|
7
|
+
# Helper Files
|
8
|
+
require 'pepipost/api_helper.rb'
|
9
|
+
require 'pepipost/api_exception.rb'
|
10
|
+
require 'pepipost/configuration.rb'
|
11
|
+
require 'pepipost/pepipost_client.rb'
|
12
|
+
|
13
|
+
# Controllers
|
14
|
+
require 'pepipost/controllers/email_controller.rb'
|
15
|
+
|
16
|
+
# Models
|
17
|
+
require 'pepipost/models/attributes.rb'
|
18
|
+
require 'pepipost/models/files.rb'
|
19
|
+
require 'pepipost/models/emailv_1.rb'
|
20
|
+
require 'pepipost/models/email_details.rb'
|
21
|
+
require 'pepipost/models/settings.rb'
|
22
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class APIException < StandardError
|
3
|
+
# value store
|
4
|
+
attr_reader :response_code
|
5
|
+
|
6
|
+
# value store
|
7
|
+
attr_reader :response_body
|
8
|
+
|
9
|
+
# The HTTP response code from the API request
|
10
|
+
# @param [String] the reason for raising an exception
|
11
|
+
# @param [Numeric] the HTTP response code from the API request
|
12
|
+
# @param [Object] the HTTP unprased response from the API request
|
13
|
+
def initialize(reason, response_code, response_body)
|
14
|
+
super(reason)
|
15
|
+
@response_code = response_code
|
16
|
+
@response_body = response_body
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class APIHelper
|
3
|
+
# Replaces template parameters in the given url
|
4
|
+
# @param [String] The query string builder to replace the template parameters
|
5
|
+
# @param [Array] The parameters to replace in the url
|
6
|
+
def self.append_url_with_template_parameters(query_builder, parameters)
|
7
|
+
# perform parameter validation
|
8
|
+
raise ArgumentError, 'Given value for parameter \"query_builder\" is invalid.' unless query_builder.is_a? String
|
9
|
+
|
10
|
+
# return if there are no parameters to replace
|
11
|
+
abort('no parameters to append') if parameters.nil?
|
12
|
+
|
13
|
+
# iterate and append parameters
|
14
|
+
parameters.map do |key, value|
|
15
|
+
replace_value = ''
|
16
|
+
|
17
|
+
if value.nil?
|
18
|
+
replace_value = ''
|
19
|
+
elsif value.is_a? Enumerable
|
20
|
+
replace_value = value.join('/')
|
21
|
+
else
|
22
|
+
replace_value = value.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
# find the template parameter and replace it with its value
|
26
|
+
query_builder = query_builder.gsub('{' + key.to_s + '}', replace_value)
|
27
|
+
end
|
28
|
+
|
29
|
+
query_builder
|
30
|
+
end
|
31
|
+
|
32
|
+
# Appends the given set of parameters to the given query string
|
33
|
+
# @param [String] The query string builder to replace the template parameters
|
34
|
+
# @param [Array] The parameters to append
|
35
|
+
def self.append_url_with_query_parameters(query_builder, parameters)
|
36
|
+
# perform parameter validation
|
37
|
+
raise ArgumentError, 'Given value for parameter \"query_builder\" is invalid.' unless query_builder.is_a? String
|
38
|
+
|
39
|
+
# return if there are no parameters to replace
|
40
|
+
abort('no parameters to append') if parameters.nil?
|
41
|
+
|
42
|
+
# remove any nil values
|
43
|
+
parameters = parameters.reject { |_key, value| value.nil? }
|
44
|
+
|
45
|
+
# does the query string already has parameters
|
46
|
+
has_params = query_builder.include? '?'
|
47
|
+
separator = has_params ? '&' : '?'
|
48
|
+
|
49
|
+
# append query with separator and parameters
|
50
|
+
query_builder << separator << URI.unescape(URI.encode_www_form(parameters))
|
51
|
+
end
|
52
|
+
|
53
|
+
# Validates and processes the given Url
|
54
|
+
# @param [String] The given Url to process
|
55
|
+
# @return [String] Pre-processed Url as string
|
56
|
+
def self.clean_url(url)
|
57
|
+
# perform parameter validation
|
58
|
+
raise ArgumentError, 'Invalid Url.' unless url.is_a? String
|
59
|
+
|
60
|
+
# ensure that the urls are absolute
|
61
|
+
matches = url.match(%r{^(https?:\/\/[^\/]+)})
|
62
|
+
raise ArgumentError, 'Invalid Url format.' if matches.nil?
|
63
|
+
|
64
|
+
# get the http protocol match
|
65
|
+
protocol = matches[1]
|
66
|
+
|
67
|
+
# remove redundant forward slashes
|
68
|
+
query = url[protocol.length..-1].gsub(%r{\/\/+}, '/')
|
69
|
+
|
70
|
+
# return process url
|
71
|
+
protocol + query
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class Email
|
3
|
+
@@instance = Email.new
|
4
|
+
# Singleton instance of the controller class
|
5
|
+
def self.instance
|
6
|
+
@@instance
|
7
|
+
end
|
8
|
+
|
9
|
+
# `Sending Mails` – This API is used for sending emails. Pepipost supports REST as well JSON formats for the input
|
10
|
+
# @param [String] api_key Required parameter: Your API Key
|
11
|
+
# @param [String] content Required parameter: Email body in html (to use attributes to display dynamic values such as name, account number, etc. for ex. [% NAME %] for ATT_NAME , [% AGE %] for ATT_AGE etc.)
|
12
|
+
# @param [String] from Required parameter: From email address
|
13
|
+
# @param [String] recipients Required parameter: Email addresses for recipients (multiple values allowed)
|
14
|
+
# @param [String] subject Required parameter: Subject of the Email
|
15
|
+
# @param [String] att_name Optional parameter: Specify attributes followed by ATT_ for recipient to personalized email for ex. ATT_NAME for name, ATT_AGE for age etc. (Multiple attributes are allowed)
|
16
|
+
# @param [String] attachmentid Optional parameter: specify uploaded attachments id (Multiple attachments are allowed)
|
17
|
+
# @param [String] bcc Optional parameter: Email address for bcc
|
18
|
+
# @param [Boolean] clicktrack Optional parameter: set ‘0’ or ‘1’ in-order to disable or enable the click-track
|
19
|
+
# @param [Boolean] footer Optional parameter: Set '0' or '1' in order to include footer or not
|
20
|
+
# @param [String] fromname Optional parameter: Email Sender name
|
21
|
+
# @param [Boolean] opentrack Optional parameter: set open-track value to ‘0’ or ‘1’ in-order to disable or enable
|
22
|
+
# @param [String] replytoid Optional parameter: Reply to email address
|
23
|
+
# @param [String] tags Optional parameter: To relate each message. Useful for reports.
|
24
|
+
# @param [Numeric] template Optional parameter: Email template ID
|
25
|
+
# @param [String] x_apiheader Optional parameter: Your defined unique identifier
|
26
|
+
# @return mixed response from the API call
|
27
|
+
def get_api_web_send_rest(api_key, content, from, recipients, subject, att_name = nil, attachmentid = nil, bcc = nil, clicktrack = true, footer = true, fromname = nil, opentrack = true, replytoid = nil, tags = nil, template = nil, x_apiheader = nil)
|
28
|
+
# the base uri for api requests
|
29
|
+
query_builder = Configuration.base_uri.dup
|
30
|
+
|
31
|
+
# prepare query string for API call
|
32
|
+
query_builder << '/api/web.send.rest'
|
33
|
+
|
34
|
+
# process optional query parameters
|
35
|
+
query_builder = APIHelper.append_url_with_query_parameters query_builder, {
|
36
|
+
'api_key' => api_key,
|
37
|
+
'content' => content,
|
38
|
+
'from' => from,
|
39
|
+
'recipients' => recipients,
|
40
|
+
'subject' => subject,
|
41
|
+
'ATT_NAME' => att_name,
|
42
|
+
'attachmentid' => attachmentid,
|
43
|
+
'bcc' => bcc,
|
44
|
+
'clicktrack' => if clicktrack.nil? then true else clicktrack end,
|
45
|
+
'footer' => if footer.nil? then true else footer end,
|
46
|
+
'fromname' => fromname,
|
47
|
+
'opentrack' => if opentrack.nil? then true else opentrack end,
|
48
|
+
'replytoid' => replytoid,
|
49
|
+
'tags' => tags,
|
50
|
+
'template' => template,
|
51
|
+
'X-APIHEADER' => x_apiheader
|
52
|
+
}
|
53
|
+
|
54
|
+
# validate and preprocess url
|
55
|
+
query_url = APIHelper.clean_url query_builder
|
56
|
+
|
57
|
+
# prepare headers
|
58
|
+
headers = {
|
59
|
+
'user-agent' => 'APIMATIC 2.0',
|
60
|
+
'accept' => 'application/json'
|
61
|
+
}
|
62
|
+
|
63
|
+
# invoke the API call request to fetch the response
|
64
|
+
response = Unirest.get query_url, headers: headers
|
65
|
+
|
66
|
+
#Error handling using HTTP status codes
|
67
|
+
if !response.code.between?(200, 206) # [200,206] = HTTP OK
|
68
|
+
raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
|
69
|
+
end
|
70
|
+
|
71
|
+
response.body
|
72
|
+
end
|
73
|
+
|
74
|
+
# This is a common function send email using Pepipost API
|
75
|
+
def send(data)
|
76
|
+
response = self.create_api_web_send_json(data)
|
77
|
+
return response
|
78
|
+
end
|
79
|
+
|
80
|
+
# `Sending Mails` – This API is used for sending emails. Pepipost supports REST as well JSON formats for the input. This is JSON API.
|
81
|
+
# @param [Emailv1] data Required parameter: Data in JSON format
|
82
|
+
# @return mixed response from the API call
|
83
|
+
def create_api_web_send_json(data)
|
84
|
+
# the base uri for api requests
|
85
|
+
query_builder = Configuration.base_uri.dup
|
86
|
+
|
87
|
+
# prepare query string for API call
|
88
|
+
query_builder << '/api/web.send.json'
|
89
|
+
|
90
|
+
# validate and preprocess url
|
91
|
+
query_url = APIHelper.clean_url query_builder
|
92
|
+
|
93
|
+
# prepare headers
|
94
|
+
headers = {
|
95
|
+
'user-agent' => 'APIMATIC 2.0',
|
96
|
+
'accept' => 'application/json',
|
97
|
+
'content-type' => 'application/json; charset=utf-8'
|
98
|
+
}
|
99
|
+
|
100
|
+
# invoke the API call request to fetch the response
|
101
|
+
response = Unirest.post query_url, headers: headers, parameters: data.to_json
|
102
|
+
|
103
|
+
#Error handling using HTTP status codes
|
104
|
+
if !response.code.between?(200, 206) # [200,206] = HTTP OK
|
105
|
+
raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
|
106
|
+
end
|
107
|
+
|
108
|
+
response.body
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class Attributes
|
3
|
+
# TODO: Write general description for this method
|
4
|
+
# @return [Array<String>]
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
# TODO: Write general description for this method
|
8
|
+
# @return [Array<String>]
|
9
|
+
attr_accessor :regid
|
10
|
+
|
11
|
+
def method_missing(method_name)
|
12
|
+
puts "there's no method called '#{method_name}'"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Creates JSON of the curent object
|
16
|
+
def to_json
|
17
|
+
hash = key_map
|
18
|
+
hash.to_json
|
19
|
+
end
|
20
|
+
|
21
|
+
# Defines the key map for json serialization
|
22
|
+
def key_map
|
23
|
+
hash = {}
|
24
|
+
hash['NAME'] = name
|
25
|
+
hash['REGID'] = regid
|
26
|
+
hash
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class EmailDetails
|
3
|
+
# TODO: Write general description for this method
|
4
|
+
# @return [String]
|
5
|
+
attr_accessor :fromname
|
6
|
+
|
7
|
+
# TODO: Write general description for this method
|
8
|
+
# @return [String]
|
9
|
+
attr_accessor :subject
|
10
|
+
|
11
|
+
# TODO: Write general description for this method
|
12
|
+
# @return [String]
|
13
|
+
attr_accessor :from
|
14
|
+
|
15
|
+
# TODO: Write general description for this method
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :replytoid
|
18
|
+
|
19
|
+
# TODO: Write general description for this method
|
20
|
+
# @return [String]
|
21
|
+
attr_accessor :tags
|
22
|
+
|
23
|
+
# TODO: Write general description for this method
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :content
|
26
|
+
|
27
|
+
def method_missing(method_name)
|
28
|
+
puts "there's no method called '#{method_name}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Creates JSON of the curent object
|
32
|
+
def to_json
|
33
|
+
hash = key_map
|
34
|
+
hash.to_json
|
35
|
+
end
|
36
|
+
|
37
|
+
# Defines the key map for json serialization
|
38
|
+
def key_map
|
39
|
+
hash = {}
|
40
|
+
hash['fromname'] = fromname
|
41
|
+
hash['subject'] = subject
|
42
|
+
hash['from'] = from
|
43
|
+
hash['replytoid'] = replytoid
|
44
|
+
hash['tags'] = tags
|
45
|
+
hash['content'] = content
|
46
|
+
hash
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class Emailv1
|
3
|
+
# Your secret API Key
|
4
|
+
# @return [String]
|
5
|
+
attr_accessor :api_key
|
6
|
+
|
7
|
+
# TODO: Write general description for this method
|
8
|
+
# @return [EmailDetails]
|
9
|
+
attr_accessor :email_details
|
10
|
+
|
11
|
+
# TODO: Write general description for this method
|
12
|
+
# @return [Array<String>]
|
13
|
+
attr_accessor :x_apiheader
|
14
|
+
|
15
|
+
# TODO: Write general description for this method
|
16
|
+
# @return [Settings]
|
17
|
+
attr_accessor :settings
|
18
|
+
|
19
|
+
# TODO: Write general description for this method
|
20
|
+
# @return [Array<String>]
|
21
|
+
attr_accessor :recipients
|
22
|
+
|
23
|
+
# TODO: Write general description for this method
|
24
|
+
# @return [Attributes]
|
25
|
+
attr_accessor :attributes
|
26
|
+
|
27
|
+
# TODO: Write general description for this method
|
28
|
+
# @return [Files]
|
29
|
+
attr_accessor :files
|
30
|
+
|
31
|
+
def method_missing(method_name)
|
32
|
+
puts "there's no method called '#{method_name}'"
|
33
|
+
end
|
34
|
+
|
35
|
+
# Creates JSON of the curent object
|
36
|
+
def to_json
|
37
|
+
hash = key_map
|
38
|
+
hash.to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
# Defines the key map for json serialization
|
42
|
+
def key_map
|
43
|
+
hash = {}
|
44
|
+
hash['api_key'] = api_key
|
45
|
+
hash['email_details'] = email_details
|
46
|
+
hash['X-APIHEADER'] = x_apiheader
|
47
|
+
hash['settings'] = settings
|
48
|
+
hash['recipients'] = recipients
|
49
|
+
hash['attributes'] = attributes
|
50
|
+
hash['files'] = files
|
51
|
+
hash
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class Files
|
3
|
+
# TODO: Write general description for this method
|
4
|
+
# @return [String]
|
5
|
+
attr_accessor :example_attachment_1_txt
|
6
|
+
|
7
|
+
def method_missing(method_name)
|
8
|
+
puts "there's no method called '#{method_name}'"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Creates JSON of the curent object
|
12
|
+
def to_json
|
13
|
+
hash = key_map
|
14
|
+
hash.to_json
|
15
|
+
end
|
16
|
+
|
17
|
+
# Defines the key map for json serialization
|
18
|
+
def key_map
|
19
|
+
hash = {}
|
20
|
+
hash['example_attachment1.txt'] = example_attachment_1_txt
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Pepipost
|
2
|
+
class Settings
|
3
|
+
# TODO: Write general description for this method
|
4
|
+
# @return [Boolean]
|
5
|
+
attr_accessor :footer
|
6
|
+
|
7
|
+
# TODO: Write general description for this method
|
8
|
+
# @return [Boolean]
|
9
|
+
attr_accessor :clicktrack
|
10
|
+
|
11
|
+
# TODO: Write general description for this method
|
12
|
+
# @return [Boolean]
|
13
|
+
attr_accessor :opentrack
|
14
|
+
|
15
|
+
# TODO: Write general description for this method
|
16
|
+
# @return [Boolean]
|
17
|
+
attr_accessor :unsubscribe
|
18
|
+
|
19
|
+
# TODO: Write general description for this method
|
20
|
+
# @return [String]
|
21
|
+
attr_accessor :bcc
|
22
|
+
|
23
|
+
# TODO: Write general description for this method
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :attachmentid
|
26
|
+
|
27
|
+
# TODO: Write general description for this method
|
28
|
+
# @return [Numeric]
|
29
|
+
attr_accessor :template
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@footer = true
|
33
|
+
@clicktrack = true
|
34
|
+
@opentrack = true
|
35
|
+
@unsubscribe = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def method_missing(method_name)
|
39
|
+
puts "there's no method called '#{method_name}'"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Creates JSON of the curent object
|
43
|
+
def to_json
|
44
|
+
hash = key_map
|
45
|
+
hash.to_json
|
46
|
+
end
|
47
|
+
|
48
|
+
# Defines the key map for json serialization
|
49
|
+
def key_map
|
50
|
+
hash = {}
|
51
|
+
hash['footer'] = footer
|
52
|
+
hash['clicktrack'] = clicktrack
|
53
|
+
hash['opentrack'] = opentrack
|
54
|
+
hash['unsubscribe'] = unsubscribe
|
55
|
+
hash['bcc'] = bcc
|
56
|
+
hash['attachmentid'] = attachmentid
|
57
|
+
hash['template'] = template
|
58
|
+
hash
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Require controllers
|
2
|
+
require 'pepipost/controllers/email_controller.rb'
|
3
|
+
|
4
|
+
module Pepipost
|
5
|
+
class PepipostClient
|
6
|
+
# Singleton access to email controller
|
7
|
+
# @return [EmailController] Returns the controller instance
|
8
|
+
def email
|
9
|
+
EmailController.instance
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/pepipost.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pepipost/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pepipost"
|
8
|
+
spec.version = Pepipost::VERSION
|
9
|
+
spec.authors = ["Mikhail Mandronov"]
|
10
|
+
spec.email = ["mmandronov@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby Rails gem for pepipost service}
|
12
|
+
spec.description = %q{Ruby gem - wrapper of official pepipost sdk}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'unirest'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pepipost
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mikhail Mandronov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unirest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Ruby gem - wrapper of official pepipost sdk
|
56
|
+
email:
|
57
|
+
- mmandronov@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/pepipost.rb
|
68
|
+
- lib/pepipost/api_exception.rb
|
69
|
+
- lib/pepipost/api_helper.rb
|
70
|
+
- lib/pepipost/configuration.rb
|
71
|
+
- lib/pepipost/controllers/email_controller.rb
|
72
|
+
- lib/pepipost/models/attributes.rb
|
73
|
+
- lib/pepipost/models/email_details.rb
|
74
|
+
- lib/pepipost/models/emailv_1.rb
|
75
|
+
- lib/pepipost/models/files.rb
|
76
|
+
- lib/pepipost/models/settings.rb
|
77
|
+
- lib/pepipost/pepipost_client.rb
|
78
|
+
- lib/pepipost/version.rb
|
79
|
+
- pepipost.gemspec
|
80
|
+
homepage: ''
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.2.2
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Ruby Rails gem for pepipost service
|
104
|
+
test_files: []
|