salesfly 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 599ba7706262fed0514e9e27631ed5c61be2d14ca9b1a4cf8a8a3542f27e62ee
4
+ data.tar.gz: abd507cfdf2ec7c8e5106cb6ff0e0521455cce98b0680c8af8f89022299a2458
5
+ SHA512:
6
+ metadata.gz: 53271a1fa88772d76bc1890c4eba5b2416a5190d05e079b314037605cd23ef9fff9ac7454fa90ff7694fa85a90c9cc6fa231b07c4b99f43746171bf3569bc0fb
7
+ data.tar.gz: 41f1c95a8f48f9b10e406847615b8a80866e2063c79f806d647143b3fb8b3879fadbabf4dc15ff2bb850eb7e93369e8b6ec344d15ad96a54fa2cc7003fe6e6bf
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-20 UAB Salesfly.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # salesfly-ruby
2
+
3
+ [![Build Status](https://travis-ci.org/salesfly/salesfly-ruby.svg?branch=master)](https://travis-ci.org/salesfly/salesfly-ruby)
4
+
5
+ <!--[![codecov](https://codecov.io/gh/salesfly/salesfly-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/salesfly/salesfly-ruby)-->
6
+
7
+ Ruby client for [Salesfly API](https://salesfly.com)&reg;
8
+
9
+ ## Documentation
10
+
11
+ See the [Ruby API docs](https://docs.salesfly.com/ruby/).
12
+
13
+ ## Installation
14
+
15
+ You don't need this source code unless you want to modify the package. If you just
16
+ want to use the package, just run:
17
+
18
+ ```bash
19
+ gem install salesfly
20
+ ```
21
+
22
+ ### Requirements
23
+
24
+ - Ruby 2.2 or later
25
+
26
+ ## Usage
27
+
28
+ The library needs to be configured with your account's API key. Get your own API key by signing up for a free [Salesfly account](https://salesfly.com).
29
+
30
+ ```ruby
31
+ require "salesfly"
32
+
33
+ api_key = ENV["SALESFLY_APIKEY"]
34
+
35
+ client = Salesfly::Client.new({
36
+ api_key: api_key,
37
+ })
38
+ location = client.geoip.get("8.8.8.8")
39
+ print "Country code: ", location["country_code"]
40
+ ```
41
+
42
+ ## License and Trademarks
43
+
44
+ Copyright (c) 2018-20 UAB Salesfly.
45
+
46
+ Licensed under the [MIT license](https://en.wikipedia.org/wiki/MIT_License).
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining a copy
49
+ of this software and associated documentation files (the "Software"), to deal
50
+ in the Software without restriction, including without limitation the rights
51
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52
+ copies of the Software, and to permit persons to whom the Software is
53
+ furnished to do so, subject to the following conditions:
54
+
55
+ The above copyright notice and this permission notice shall be included in all
56
+ copies or substantial portions of the Software.
57
+
58
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64
+ SOFTWARE.
65
+
66
+ Salesfly is a registered trademark of [UAB Salesfly](https://www.salesfly.com).
@@ -0,0 +1,39 @@
1
+ module Salesfly
2
+ class Client
3
+ ##
4
+ # A client for accessing the Salesfly API.
5
+
6
+ def initialize(options = {})
7
+ @rest_client = Salesfly::REST.new(options)
8
+ @usage_api = Salesfly::UsageAPI.new(@rest_client)
9
+ @geoip_api = Salesfly::GeoLocationAPI.new(@rest_client)
10
+ @mail_api = Salesfly::MailAPI.new(@rest_client)
11
+ @pdf_api = Salesfly::PDFAPI.new(@rest_client)
12
+ end
13
+
14
+ def api_key
15
+ @rest_client.api_key
16
+ end
17
+
18
+ def version()
19
+ VERSION
20
+ end
21
+
22
+ def usage()
23
+ @usage_api
24
+ end
25
+
26
+ def geoip()
27
+ @geoip_api
28
+ end
29
+
30
+ def mail()
31
+ @mail_api
32
+ end
33
+
34
+ def pdf()
35
+ @pdf_api
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ module Salesfly
2
+ class APIConnectionError < APIError
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Salesfly
2
+ class APIError < StandardError
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Salesfly
2
+ class APITimeoutError < APIError
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module Salesfly
2
+ class ResponseError < APIError
3
+ attr_reader :status, :code
4
+
5
+ def initialize(msg="", status=400, code="")
6
+ @status = status
7
+ @code = code
8
+ super(msg)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ module Salesfly
2
+ class GeoLocationAPI
3
+
4
+ def initialize(rest_client)
5
+ @rest_client = rest_client
6
+ end
7
+
8
+ def get(ip, options={})
9
+ query = URI.encode_www_form(options)
10
+ return @rest_client.get("/v1/geoip/#{ip}?#{query}")
11
+ end
12
+
13
+ def get_current(options={})
14
+ return self.get("myip", options)
15
+ end
16
+
17
+ def get_bulk(ip_list, options={})
18
+ ip = ip_list.join(",")
19
+ return self.get(ip, options)
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,129 @@
1
+ module Salesfly
2
+ class MailAPI
3
+
4
+ SCHEMA = {
5
+ "type" => "object",
6
+ "properties" => {
7
+ "date" => {
8
+ "type" => "string",
9
+ "format" => "date-time"
10
+ },
11
+ "from" => {
12
+ "type" => "string",
13
+ "maxLength" => 50
14
+ },
15
+ "from_name" => {
16
+ "type" => "string",
17
+ "maxLength" => 50
18
+ },
19
+ "to" => {
20
+ "type" => "array",
21
+ "minLength" => 1,
22
+ "maxLength" => 50,
23
+ "items" => {
24
+ "type" => "string",
25
+ }
26
+ },
27
+ "cc" => {
28
+ "type" => "array",
29
+ "minLength" => 1,
30
+ "maxLength" => 50,
31
+ "items" => {
32
+ "type" => "string"
33
+ }
34
+ },
35
+ "bcc" => {
36
+ "type" => "array",
37
+ "minLength" => 1,
38
+ "maxLength" => 50,
39
+ "items" => {
40
+ "type" => "string"
41
+ }
42
+ },
43
+ "reply_to" => {
44
+ "type" => "string",
45
+ "maxLength" => 50
46
+ },
47
+ "subject" => {
48
+ "type" => "string",
49
+ "maxLength" => 100
50
+ },
51
+ "text" => {
52
+ "type" => "string"
53
+ },
54
+ "html" => {
55
+ "type" => "string"
56
+ },
57
+ "attachments" => {
58
+ "type" => "array",
59
+ "maxLength" => 10,
60
+ "items" => {
61
+ "type" => "string"
62
+ }
63
+ },
64
+ "tags" => {
65
+ "type" => "array",
66
+ "maxLength" => 3,
67
+ "items" => {
68
+ "type" => "string",
69
+ "maxLength" => 20,
70
+ }
71
+ },
72
+ "charset" => {
73
+ "type" => "string",
74
+ "maxLength" => 20
75
+ },
76
+ "encoding" => {
77
+ "type" => "string",
78
+ "maxLength" => 20
79
+ },
80
+ "require_tls" => {
81
+ "type" => "boolean"
82
+ },
83
+ "verify_cert" => {
84
+ "type" => "boolean"
85
+ },
86
+ "open_tracking" => {
87
+ "type" => "boolean"
88
+ },
89
+ "click_tracking" => {
90
+ "type" => "boolean"
91
+ },
92
+ "text_click_tracking" => {
93
+ "type" => "boolean"
94
+ },
95
+ "unsubscribe_tracking" => {
96
+ "type" => "boolean"
97
+ },
98
+ "test_mode" => {
99
+ "type" => "boolean"
100
+ }
101
+ },
102
+ "required" => ["from", "to", "subject", "text"],
103
+ "additionalProperties" => false
104
+ }
105
+
106
+ def initialize(rest_client)
107
+ @rest_client = rest_client
108
+ end
109
+
110
+ def send(message)
111
+ # Validate message
112
+ begin
113
+ JSON::Validator.validate!(SCHEMA, message, :strict => false)
114
+ rescue JSON::Schema::ValidationError => e
115
+ raise ArgumentError.new("Message has missing or invalid attributes")
116
+ end
117
+ # Extract files
118
+ files = []
119
+ if message.key?("attachments")
120
+ files = message["attachments"]
121
+ message = message.reject { |k,v| k == "attachments" }
122
+ end
123
+ multipart = Multipart.new
124
+ content, headers = multipart.encode(message, files)
125
+ return @rest_client.post("/v1/mail/send", content, headers)
126
+ end
127
+
128
+ end
129
+ end
@@ -0,0 +1,78 @@
1
+ require 'mime/types'
2
+ require 'cgi'
3
+
4
+ module Salesfly
5
+ VERSION = "1.0.0" unless const_defined?(:VERSION)
6
+
7
+ class Multipart
8
+ def encode(params, files)
9
+ boundary = self.get_random_string()
10
+ lines = []
11
+
12
+ params.each do |key, value|
13
+ if value.kind_of?(Array)
14
+ value.each do |v|
15
+ lines.push(StringParam.new(key, v))
16
+ end
17
+ else
18
+ lines.push(StringParam.new(key, value))
19
+ end
20
+ end
21
+
22
+ files.each do |fn|
23
+ lines.push(FileParam.new(fn))
24
+ end
25
+
26
+ content = lines.collect {|p| "--" + boundary + "\r\n" + p.to_multipart }.join("") + "--" + boundary + "--"
27
+ headers = {
28
+ "Content-Type" => "multipart/form-data; boundary=#{ boundary }",
29
+ "Content-Length" => content.length.to_s
30
+ }
31
+ return content, headers
32
+ end
33
+
34
+ def get_random_string(length=32)
35
+ source=("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a
36
+ key=""
37
+ length.times{ key += source[rand(source.size)].to_s }
38
+ return key
39
+ end
40
+
41
+ end
42
+
43
+ private
44
+
45
+ # Formats a basic string key/value pair for inclusion with a multipart post
46
+ class StringParam
47
+ attr_accessor :name, :value
48
+
49
+ def initialize(k, v)
50
+ @name = k
51
+ @value = v
52
+ end
53
+
54
+ def to_multipart
55
+ return "Content-Disposition: form-data; name=\"#{CGI::escape(name)}\"\r\n\r\n#{value}\r\n"
56
+ end
57
+ end
58
+
59
+ # Formats the contents of a file or string for inclusion with a multipart
60
+ # form post
61
+ class FileParam
62
+ attr_accessor :name, :filename, :content
63
+
64
+ def initialize(filename)
65
+ @name = File.basename(filename)
66
+ @filename = filename
67
+ @content = File.read(filename)
68
+ end
69
+
70
+ def to_multipart
71
+ # If we can tell the possible mime-type from the filename, use the
72
+ # first in the list; otherwise, use "application/octet-stream"
73
+ mime_type = MIME::Types.type_for(filename)[0] || MIME::Types["application/octet-stream"][0]
74
+ return "Content-Disposition: form-data; name=\"#{CGI::escape(name)}\"; filename=\"#{ filename }\"\r\n" +
75
+ "Content-Type: #{ mime_type.simplified }\r\n\r\n#{ content }\r\n"
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,16 @@
1
+ module Salesfly
2
+ class PDFAPI
3
+
4
+ def initialize(rest_client)
5
+ @rest_client = rest_client
6
+ end
7
+
8
+ def create(options)
9
+ headers = {
10
+ "Accept" => "application/pdf"
11
+ }
12
+ return @rest_client.post("/v1/pdf/create", options, headers)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,110 @@
1
+ module Salesfly
2
+ class REST
3
+
4
+ def initialize(options = {})
5
+ @api_key = options[:api_key]
6
+ @api_base_url = options.fetch(:api_base_url) { "https://api.salesfly.com" }
7
+ @timeout = options.fetch(:timeout) { 30 }
8
+ @user_agent = "salesfly-ruby/#{VERSION}"
9
+ end
10
+
11
+ def api_key
12
+ if @api_key.to_s.empty?
13
+ raise ArgumentError.new("No API key provided")
14
+ end
15
+ @api_key
16
+ end
17
+
18
+ def get(path, headers={})
19
+ execute("GET", path, nil, headers)
20
+ end
21
+
22
+ def post(path, data, headers={})
23
+ execute("POST", path, data, headers)
24
+ end
25
+
26
+ def put(path, data, headers={})
27
+ execute("PUT", path, data, headers)
28
+ end
29
+
30
+ def patch(path, data, headers={})
31
+ execute("PATCH", path, data, headers)
32
+ end
33
+
34
+ def delete(path, headers={})
35
+ execute("DELETE", path, nil, headers)
36
+ end
37
+
38
+ def execute(method, path, data, headers={})
39
+ std_headers = {
40
+ "User-Agent" => @user_agent,
41
+ "Authorization" => "Bearer #{api_key}",
42
+ "Accept" => "application/json",
43
+ "Content-Type" => "application/json"
44
+ }
45
+ headers = std_headers.merge(headers)
46
+
47
+ begin
48
+ RestClient::Request.execute(method: method, url: @api_base_url + path, payload: data, headers: headers, timeout: @timeout) { |response, request, result, &block|
49
+ # print &block
50
+ case response.code
51
+ when 200, 201
52
+ if headers["Accept"] == "application/pdf"
53
+ return response
54
+ end
55
+ body = JSON.parse(response)
56
+ return body["data"]
57
+ else
58
+ begin
59
+ err = JSON.parse(response)
60
+ raise ResponseError.new(err["message"], response.code, err["code"])
61
+ rescue JSON::ParserError
62
+ raise ResponseError.new(response.body, response.code) # code?
63
+ rescue Timeout::Error, Net::ReadTimeout => e
64
+ raise APITimeoutError.new(e.message)
65
+ rescue Errno::ECONNREFUSED, Errno::EINVAL, Errno::ECONNRESET, EOFError,
66
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
67
+ SocketError => e
68
+ raise APIConnectionError.new(e.message)
69
+ end
70
+ end
71
+ }
72
+ end
73
+
74
+
75
+ # begin
76
+ # case method
77
+ # when "GET"
78
+ # resp = self.class.get(path, base_uri: @api_base_url, timeout: @timeout, :headers => headers)
79
+ # when "POST"
80
+ # resp = self.class.post(path, base_uri: @api_base_url, timeout: @timeout, :headers => headers, :body => data, multipart: true)
81
+ # when "PUT"
82
+ # resp = self.class.put(path, base_uri: @api_base_url, timeout: @timeout, :headers => headers, :body => data)
83
+ # when "PATCH"
84
+ # resp = self.class.patch(path, base_uri: @api_base_url, timeout: @timeout, :headers => headers, :body => data)
85
+ # when "DELETE"
86
+ # resp = self.class.delete(path, base_uri: @api_base_url, timeout: @timeout, :headers => headers)
87
+ # end
88
+
89
+ # if [200,201].include?(resp.code)
90
+ # result = JSON.parse(resp.body) #FIXME: Handle 204 No content
91
+ # return result["data"]
92
+ # else
93
+ # begin
94
+ # err = JSON.parse(resp.body)
95
+ # raise ResponseError.new(err["message"], resp.code, err["code"])
96
+ # rescue JSON::ParserError
97
+ # raise ResponseError.new(resp.message, resp.code) # code?
98
+ # end
99
+ # end
100
+ # rescue Timeout::Error, Net::ReadTimeout => e
101
+ # raise APITimeoutError.new(e.message)
102
+ # rescue Errno::ECONNREFUSED, Errno::EINVAL, Errno::ECONNRESET, EOFError,
103
+ # Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
104
+ # HTTParty::Error, SocketError => e
105
+ # raise APIConnectionError.new(e.message)
106
+ # end
107
+ end
108
+
109
+ end
110
+ end
@@ -0,0 +1,13 @@
1
+ module Salesfly
2
+ class UsageAPI
3
+
4
+ def initialize(rest_client)
5
+ @rest_client = rest_client
6
+ end
7
+
8
+ def get()
9
+ return @rest_client.get("/v1/usage")
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Salesfly
2
+ VERSION = "0.9.2"
3
+ end
data/lib/salesfly.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "rest-client"
2
+ require "json"
3
+ require "json-schema"
4
+
5
+ require "salesfly/version"
6
+ require "salesfly/errors/api_error"
7
+ require "salesfly/errors/api_connection_error"
8
+ require "salesfly/errors/api_timeout_error"
9
+ require "salesfly/errors/response_error"
10
+ require "salesfly/rest"
11
+ require "salesfly/multipart"
12
+ require "salesfly/usage_api"
13
+ require "salesfly/geoip_api"
14
+ require "salesfly/mail_api"
15
+ require "salesfly/pdf_api"
16
+ require "salesfly/client"
17
+
data/salesfly.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ require File.expand_path("lib/salesfly/version", File.dirname(__FILE__))
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "salesfly"
5
+ s.version = Salesfly::VERSION
6
+ s.authors = ["Salesfly"]
7
+ s.email = ["hello@salesfly.com"]
8
+ s.license = "MIT"
9
+ s.homepage = "https://github.com/salesfly/salesfly-ruby"
10
+ s.description = "Ruby client for Salesfly API"
11
+ s.summary = "This is the Ruby client library for the Salesfly API. To use it you will need an Salesfly account. Sign up for free at https://salesfly.com"
12
+ s.platform = Gem::Platform::RUBY
13
+ s.files = Dir.glob("{lib,test}/**/*") + %w(LICENSE README.md salesfly.gemspec)
14
+ s.required_ruby_version = ">= 2.2.0"
15
+ s.add_dependency("rest-client", "~> 2.1.0")
16
+ s.add_dependency("json-schema", "~> 2.8.0")
17
+ s.add_development_dependency("rake", "~> 12.0")
18
+ s.add_development_dependency("minitest", "~> 5.0")
19
+ s.add_development_dependency("simplecov", "~> 0.16")
20
+ s.add_development_dependency("codecov", "~> 0.1.10")
21
+ s.require_path = "lib"
22
+ end
@@ -0,0 +1,83 @@
1
+ require_relative "./helper"
2
+
3
+ module SalesflyTest
4
+ class SalesflyClientTest < SalesflyTest::Test
5
+
6
+ def test_no_api_key
7
+ assert_raises ArgumentError do
8
+ cli = Salesfly::Client.new({
9
+ api_key: "",
10
+ })
11
+ _ = cli.api_key
12
+ end
13
+ end
14
+
15
+ def test_get_version
16
+ v = client.version()
17
+ assert_equal Salesfly::VERSION, v
18
+ end
19
+
20
+ def test_get_api_usage
21
+ usage = client.usage.get()
22
+ assert_operator usage["allowed"], :>, 0
23
+ assert_operator usage["used"], :>, 0
24
+ end
25
+
26
+ def test_create_pdf
27
+ options = {
28
+ "document_url" => "https://example.com"
29
+ }.to_json
30
+ buffer = client.pdf.create(options)
31
+ assert buffer != nil
32
+ File.open("/tmp/test-ruby.pdf", "w") do |file|
33
+ file.write(buffer)
34
+ end
35
+ end
36
+
37
+ =begin
38
+ def test_get_geolocation
39
+ location = client.geoip.get("8.8.8.8")
40
+ assert_equal "US", location["country_code"]
41
+ end
42
+
43
+ def test_get_geolocation_with_options
44
+ opts = { "fields" => "country_code" }
45
+ location = client.geoip.get("8.8.8.8", opts)
46
+ assert_equal "US", location["country_code"]
47
+ end
48
+
49
+ def test_get_bulk_geolocation
50
+ begin
51
+ locations = client.geoip.get_bulk(["8.8.8.8","google.com"])
52
+ # locations.each {|loc| puts "Country code: #{loc["country_code"]}" }
53
+ assert_equal 2, locations.length
54
+ rescue Salesfly::ResponseError => e
55
+ if e.code == "err-invalid-ip"
56
+ # Handle error...
57
+ else
58
+ # Other error...
59
+ end
60
+ end
61
+ end
62
+
63
+ def test_send_mail
64
+ message = {
65
+ "from" => "ok@demo2.org",
66
+ "to" => ["ok@demo2.org"],
67
+ "subject" => "Ruby test",
68
+ "text" => "This is a test from Ruby",
69
+ "tags" => ["tag1", "tag2"],
70
+ "attachments" => ["/Users/otto/me.png"]
71
+ }
72
+ begin
73
+ receipt = client.mail.send(message)
74
+ assert_equal 1, receipt["accepted_recipients"]
75
+ rescue Salesfly::ResponseError => e
76
+ print e.message
77
+ assert(false)
78
+ end
79
+ end
80
+ =end
81
+
82
+ end
83
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "./helper"
2
+
3
+ module SalesflyTest
4
+ class SalesflyErrTest < SalesflyTest::Test
5
+
6
+ def test_response_error
7
+ begin
8
+ raise Salesfly::ResponseError.new("Not found", 404, "err-not-found")
9
+ rescue Salesfly::ResponseError => e
10
+ assert_equal "Not found", e.message
11
+ assert_equal 404, e.status
12
+ assert_equal "err-not-found", e.code
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require "simplecov"
2
+ SimpleCov.start do
3
+ track_files "/lib/**/*.rb"
4
+ add_filter "/test/"
5
+ end
6
+
7
+ if ENV["CI"] == "true"
8
+ require "codecov"
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
+ end
11
+
12
+ require "minitest/autorun"
13
+ require "json"
14
+ require "salesfly"
15
+
16
+ module SalesflyTest
17
+
18
+ class Test < Minitest::Test
19
+ def client
20
+ @client ||= Salesfly::Client.new({
21
+ api_key: ENV["SALESFLY_APIKEY"],
22
+ timeout: 10,
23
+ })
24
+ end
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: salesfly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
5
+ platform: ruby
6
+ authors:
7
+ - Salesfly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: json-schema
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.10
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.10
97
+ description: Ruby client for Salesfly API
98
+ email:
99
+ - hello@salesfly.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - LICENSE
105
+ - README.md
106
+ - lib/salesfly.rb
107
+ - lib/salesfly/client.rb
108
+ - lib/salesfly/errors/api_connection_error.rb
109
+ - lib/salesfly/errors/api_error.rb
110
+ - lib/salesfly/errors/api_timeout_error.rb
111
+ - lib/salesfly/errors/response_error.rb
112
+ - lib/salesfly/geoip_api.rb
113
+ - lib/salesfly/mail_api.rb
114
+ - lib/salesfly/multipart.rb
115
+ - lib/salesfly/pdf_api.rb
116
+ - lib/salesfly/rest.rb
117
+ - lib/salesfly/usage_api.rb
118
+ - lib/salesfly/version.rb
119
+ - salesfly.gemspec
120
+ - test/salesfly/client_test.rb
121
+ - test/salesfly/err_test.rb
122
+ - test/salesfly/helper.rb
123
+ homepage: https://github.com/salesfly/salesfly-ruby
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 2.2.0
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.0.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: This is the Ruby client library for the Salesfly API. To use it you will
146
+ need an Salesfly account. Sign up for free at https://salesfly.com
147
+ test_files: []