send_sonar 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Gemfile.ruby-18 +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +114 -0
- data/RELEASE.md +29 -0
- data/Rakefile +7 -0
- data/lib/send_sonar/client.rb +24 -0
- data/lib/send_sonar/configuration.rb +32 -0
- data/lib/send_sonar/endpoints.yml +11 -0
- data/lib/send_sonar/exceptions.rb +52 -0
- data/lib/send_sonar/version.rb +3 -0
- data/lib/send_sonar.rb +38 -0
- data/send_sonar.gemspec +28 -0
- data/spec/integrations/simple_desk_spec.rb +167 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/vcr_cassettes/add_customer.yml +52 -0
- data/spec/vcr_cassettes/add_customer_api_disabled.yml +50 -0
- data/spec/vcr_cassettes/add_customer_bad_params.yml +50 -0
- data/spec/vcr_cassettes/add_customer_bad_token.yml +50 -0
- data/spec/vcr_cassettes/add_customer_no_subscription.yml +50 -0
- data/spec/vcr_cassettes/message_customer.yml +50 -0
- data/spec/vcr_cassettes/message_customer_api_disabled.yml +50 -0
- data/spec/vcr_cassettes/message_customer_bad_params.yml +50 -0
- data/spec/vcr_cassettes/message_customer_bad_token.yml +50 -0
- data/spec/vcr_cassettes/message_customer_no_subscription.yml +50 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2469c6c91f3ccd977955543284d9ee655f8569f5
|
4
|
+
data.tar.gz: 56a82d750ac349f909ddb6a10a53e705299e0f13
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc627fbe141b9568ba36c5879a82d4a484eda23cf7bbab8be055dbee28fb0ddc3e9ded4b930b14124eff622c3c4bc4661f70295302637f2078b0b2870f567a21
|
7
|
+
data.tar.gz: 977e3359037a43ce6220d74793954f56ae7cb3d962f59039408bc8ecd39175bb056ed4381070d512920e5b24cde7892010e456f709c9fcd77efe8260479e66bc
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
Gemfile.*.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.ruby-18
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 John Gesimondo and Elijah Murray
|
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,114 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/sendsonar/send_sonar_gem.svg)](https://travis-ci.org/sendsonar/send_sonar_gem)
|
2
|
+
|
3
|
+
# Upgrading from SimpleDesk Gem
|
4
|
+
Be sure to change your initializer and API calls from `SimpleDesk` to `SendSonar`.
|
5
|
+
|
6
|
+
# SendSonar
|
7
|
+
|
8
|
+
[Sonar](https://www.sendsonar.com) is an SMS customer engagement platform that allows companies to have 2-way conversations with their customers over SMS - whether it's for sales, customer service, funnel abandonment, or transactional messages.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'send_sonar'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
## Compatibility
|
23
|
+
Works with Ruby 1.8.7 or greater
|
24
|
+
|
25
|
+
## Changes
|
26
|
+
See RELEASE.md
|
27
|
+
|
28
|
+
* Configuration is now done through an initializer
|
29
|
+
* Support for sandbox server
|
30
|
+
* When creating a customer, properties is no longer a separate param (see readme)
|
31
|
+
|
32
|
+
|
33
|
+
## Setup
|
34
|
+
Initialize the gem by creating an initializer.
|
35
|
+
|
36
|
+
* Your production token can be found at https://www.sendsonar.com/api_info.
|
37
|
+
* Your sandbox token can be found at https://sandbox.sendsonar.com/api_info
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# config/initializers/send_sonar.rb
|
41
|
+
|
42
|
+
SendSonar.configure do |config|
|
43
|
+
if Rails.env.production?
|
44
|
+
config.env = :live
|
45
|
+
config.token = ENV['SONAR_PRODUCTION_TOKEN'] || 'YOUR_PRODUCTION_TOKEN'
|
46
|
+
|
47
|
+
elsif Rails.env.staging?
|
48
|
+
config.env = :sandbox
|
49
|
+
config.token = ENV['SONAR_SANDBOX_TOKEN'] || 'YOUR_PRODUCTION_TOKEN'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
## Usage
|
57
|
+
|
58
|
+
The API currently allows sending messages and adding customers.
|
59
|
+
|
60
|
+
**Sending Messages**
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
SendSonar.message_customer(text: 'message text', to: '1234567890')
|
64
|
+
```
|
65
|
+
The response is a `SendSonar::Message` object with the following accessors:
|
66
|
+
|
67
|
+
* to (phone number as string)
|
68
|
+
* text
|
69
|
+
* status
|
70
|
+
|
71
|
+
Status is one of "queued" or "unsubscribed". Messages with "queued" status are usually sent within seconds. Messages with "unsubscribed" status will not be sent, as customer has previously unsubscribed from API messages.
|
72
|
+
|
73
|
+
If you send a message to a new phone number the API will automatically create a new user.
|
74
|
+
|
75
|
+
#<Sonar::Message to="1234567890", text="content!", status="queued">
|
76
|
+
|
77
|
+
**Adding Customers**
|
78
|
+
|
79
|
+
If a customer already exists with the given phone number, that customer will be updated.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
SendSonar.add_customer(
|
83
|
+
phone_number: "5555555555",
|
84
|
+
email: "user@example.com",
|
85
|
+
first_name: "john",
|
86
|
+
last_name: "doe",
|
87
|
+
properties: { great_customer: "true" }
|
88
|
+
)
|
89
|
+
```
|
90
|
+
You can send an unlimited number of properties with arbitrary keys and values.
|
91
|
+
|
92
|
+
The response is a `SendSonar::Customer` object with the following accessors:
|
93
|
+
|
94
|
+
* id
|
95
|
+
* phone_number (string)
|
96
|
+
* email
|
97
|
+
* first_name
|
98
|
+
* last_name
|
99
|
+
* subscribed (boolean)
|
100
|
+
* properties (hash)
|
101
|
+
|
102
|
+
|
103
|
+
## Support
|
104
|
+
Email api-help@sendsonar.com if you are having issues with the gem or service.
|
105
|
+
|
106
|
+
## Contributing
|
107
|
+
|
108
|
+
Please file an issue on Github and have a conversation with us before creating a pull request
|
109
|
+
|
110
|
+
1. Fork it ( https://github.com/[my-github-username]/send_sonar/fork )
|
111
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
112
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
113
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
114
|
+
5. Create a new Pull Request
|
data/RELEASE.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
v 1.0.0
|
2
|
+
-------
|
3
|
+
Configuration is now done through an initializer
|
4
|
+
Support for sandbox server
|
5
|
+
When creating a customer, properties is no longer a separate param (see readme)
|
6
|
+
|
7
|
+
v 0.3.4
|
8
|
+
-------
|
9
|
+
Added ability to send properties
|
10
|
+
|
11
|
+
v 0.3.3
|
12
|
+
-------
|
13
|
+
Remove item from to do list in readme
|
14
|
+
|
15
|
+
v 0.3.2
|
16
|
+
-------
|
17
|
+
Restructure readme
|
18
|
+
|
19
|
+
v 0.3.1
|
20
|
+
-------
|
21
|
+
Update the readme to note the dynamic token assignment
|
22
|
+
|
23
|
+
v 0.3.0
|
24
|
+
-------
|
25
|
+
Make dynamic for API token
|
26
|
+
|
27
|
+
v 0.2.0
|
28
|
+
-------
|
29
|
+
Add documentation
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module SendSonar
|
2
|
+
module Client
|
3
|
+
def self.post(url, payload, headers={}, &block)
|
4
|
+
RestClient::Request.execute(:method => :post, :url => url, :payload => payload, :headers => headers,
|
5
|
+
:open_timeout => 2, :timeout => 4, &block)
|
6
|
+
|
7
|
+
rescue Errno::ECONNREFUSED => e
|
8
|
+
raise ConnectionRefused.new(e)
|
9
|
+
|
10
|
+
rescue RestClient::RequestTimeout => e
|
11
|
+
raise RequestTimeout.new(e)
|
12
|
+
|
13
|
+
rescue RestClient::Exception => e
|
14
|
+
if e.http_code == 400
|
15
|
+
raise BadRequest.new(e)
|
16
|
+
else
|
17
|
+
response = e.response && JSON.parse(e.response) || {}
|
18
|
+
error = response["error"]
|
19
|
+
exception = error && Exceptions::EXCEPTIONS_MAP[error].new(e) || Exception::UnknownRequestError.new(e)
|
20
|
+
raise exception
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module SendSonar
|
4
|
+
class Configuration
|
5
|
+
ENV_URLS = YAML.load_file(File.expand_path('../endpoints.yml', __FILE__))
|
6
|
+
ALLOWED_ENVS = ENV_URLS.keys
|
7
|
+
|
8
|
+
attr_writer :token
|
9
|
+
|
10
|
+
def env
|
11
|
+
@env || :sandbox
|
12
|
+
end
|
13
|
+
|
14
|
+
def token
|
15
|
+
@token || raise(SendSonar::ConfigurationError.new('You need to set your token, see SendSonar Readme'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def env=(env_sym)
|
19
|
+
if ALLOWED_ENVS.include?(env_sym.to_s)
|
20
|
+
@env = env_sym.to_s
|
21
|
+
else
|
22
|
+
raise SendSonar::ConfigurationError.new("You attempted to set SendSonar env to #{env_sym}. Should be one of #{env_choices}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def env_choices
|
29
|
+
(ALLOWED_ENVS - ['local']).join(', ')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
local:
|
2
|
+
messages: http://localhost:3000/api/v1/messages
|
3
|
+
customers: http://localhost:3000/api/v1/customers
|
4
|
+
|
5
|
+
sandbox:
|
6
|
+
messages: https://sandbox.sendsonar.com/api/v1/messages
|
7
|
+
customers: https://sandbox.sendsonar.com/api/v1/customers
|
8
|
+
|
9
|
+
live:
|
10
|
+
messages: https://www.sendsonar.com/api/v1/messages
|
11
|
+
customers: https://www.sendsonar.com/api/v1/customers
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module SendSonar
|
4
|
+
class Exception < RuntimeError;end
|
5
|
+
class ConfigurationError < Exception; end
|
6
|
+
|
7
|
+
class RequestException < Exception
|
8
|
+
def initialize(original_exception)
|
9
|
+
@original_exception = original_exception
|
10
|
+
end
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
self.class.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
inspect
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class BadRequest < RequestException
|
22
|
+
def initialize(original_exception)
|
23
|
+
@original_exception = original_exception
|
24
|
+
end
|
25
|
+
|
26
|
+
def inspect
|
27
|
+
@original_exception.inspect
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
inspect
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class BadToken < RequestException; end
|
36
|
+
class NoActiveSubscription < RequestException; end
|
37
|
+
class ApiDisabledForCompany < RequestException; end
|
38
|
+
class UnknownRequestError < RequestException; end
|
39
|
+
class RequestTimeout < RequestException; end
|
40
|
+
class ConnectionRefused < RequestException; end
|
41
|
+
|
42
|
+
class Customer < OpenStruct; end
|
43
|
+
class Message < OpenStruct; end
|
44
|
+
|
45
|
+
module Exceptions
|
46
|
+
EXCEPTIONS_MAP = {
|
47
|
+
"Bad Token" => BadToken,
|
48
|
+
"No Active Subscription" => NoActiveSubscription,
|
49
|
+
"Api Disabled For Company" => ApiDisabledForCompany
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
data/lib/send_sonar.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "send_sonar/version"
|
2
|
+
require "send_sonar/configuration"
|
3
|
+
require "send_sonar/exceptions"
|
4
|
+
require "send_sonar/client"
|
5
|
+
require "rest_client"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module SendSonar
|
10
|
+
extend self
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield @config ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_customer(params)
|
17
|
+
resp = Client.post url_for(:customers), params, headers
|
18
|
+
Customer.new(JSON.parse(resp))
|
19
|
+
end
|
20
|
+
|
21
|
+
def message_customer(params)
|
22
|
+
resp = Client.post url_for(:messages), params, headers
|
23
|
+
Message.new(JSON.parse(resp))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :config
|
29
|
+
|
30
|
+
def headers
|
31
|
+
{ :token => config.token, :client => "rubygem #{SendSonar::VERSION}" }
|
32
|
+
end
|
33
|
+
|
34
|
+
def url_for(key)
|
35
|
+
Configuration::ENV_URLS[config.env.to_s][key.to_s]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/send_sonar.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'send_sonar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "send_sonar"
|
8
|
+
spec.version = SendSonar::VERSION
|
9
|
+
spec.authors = ["John Gesimondo"]
|
10
|
+
spec.email = ["john@jmondo.com"]
|
11
|
+
spec.summary = %q{Provides a clean and simple gem to connect to Sonar}
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = "http://github.com/sendsonar/send_sonar_gem"
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "vcr", "~> 2.6"
|
25
|
+
spec.add_development_dependency "webmock", "~> 1.1"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "rest-client", '~> 1.6'
|
28
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcr'
|
3
|
+
|
4
|
+
VCR.configure do |c|
|
5
|
+
c.cassette_library_dir = 'spec/vcr_cassettes'
|
6
|
+
c.hook_into :webmock # or :fakeweb
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'SendSonar' do
|
10
|
+
describe '.configure' do
|
11
|
+
context 'token' do
|
12
|
+
it 'has a setter' do
|
13
|
+
SendSonar.configure do |config|
|
14
|
+
config.token = 'YOUR_PRODUCTION_TOKEN'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'env' do
|
20
|
+
it 'has a setter' do
|
21
|
+
SendSonar.configure do |config|
|
22
|
+
config.env = :live
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'raises an error if not an allowed option' do
|
27
|
+
expect { SendSonar.configure do |config|
|
28
|
+
config.env = :bogus_env
|
29
|
+
end }.to raise_error(SendSonar::ConfigurationError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
shared_examples "a mature, error handling gem" do |context|
|
35
|
+
context 'with an invalid token' do
|
36
|
+
let(:token) { 'FAKE_TOKEN' }
|
37
|
+
|
38
|
+
it 'raises a BadToken error' do
|
39
|
+
VCR.use_cassette("#{cassette_group}_bad_token") do
|
40
|
+
expect { response }.to raise_error(SendSonar::BadToken, 'SendSonar::BadToken')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with an inactive subscription' do
|
46
|
+
let(:token) { 'tKux9Vwkt0UuTVJqGUO80MGJHCAeebpe' }
|
47
|
+
|
48
|
+
it 'raises a BadToken error' do
|
49
|
+
VCR.use_cassette("#{cassette_group}_no_subscription") do
|
50
|
+
expect { response }.to raise_error(SendSonar::NoActiveSubscription, 'SendSonar::NoActiveSubscription')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with disabled API' do
|
56
|
+
let(:token) { 'ts9mOO_O5Dc7TOBaEAQym-00RGEl3Uel' }
|
57
|
+
|
58
|
+
it 'raises a BadToken error' do
|
59
|
+
VCR.use_cassette("#{cassette_group}_api_disabled") do
|
60
|
+
expect { response }.to raise_error(SendSonar::ApiDisabledForCompany, 'SendSonar::ApiDisabledForCompany')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '.add_customer' do
|
67
|
+
before do
|
68
|
+
SendSonar.configure do |config|
|
69
|
+
config.token = token
|
70
|
+
config.env = :local
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
let(:cassette_group) { "add_customer" }
|
75
|
+
let(:response) { SendSonar.add_customer(params) }
|
76
|
+
let(:token) { '3Z9L8xFjeNmXL7Yn-pFJUBoxkVWBbl5o' }
|
77
|
+
let(:params) do
|
78
|
+
{ :phone_number => "5555555557",
|
79
|
+
:email => "user@example.com",
|
80
|
+
:first_name => "john",
|
81
|
+
:last_name => "doe",
|
82
|
+
:properties => { :great_customer => "true" } }
|
83
|
+
end
|
84
|
+
|
85
|
+
it_behaves_like "a mature, error handling gem"
|
86
|
+
|
87
|
+
context 'with invalid params' do
|
88
|
+
let(:params) do
|
89
|
+
{ :phone_numbah => "5555555558" }
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'raises a BadRequest error with hint' do
|
93
|
+
VCR.use_cassette("add_customer_bad_params") do
|
94
|
+
expect { response }.to raise_error(SendSonar::BadRequest,
|
95
|
+
'400 Bad Request: {"error":"phone_number is missing"}')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'with proper params, active subscription' do
|
101
|
+
it 'returns a new customer' do
|
102
|
+
VCR.use_cassette('add_customer') do
|
103
|
+
expect(response).to be_a(SendSonar::Customer)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'includes the expected attributes' do
|
108
|
+
VCR.use_cassette('add_customer') do
|
109
|
+
customer = response
|
110
|
+
expect(customer.phone_number).to eq("5555555557")
|
111
|
+
expect(customer.email).to eq("user@example.com")
|
112
|
+
expect(customer.first_name).to eq("john")
|
113
|
+
expect(customer.last_name).to eq("doe")
|
114
|
+
expect(customer.properties).to eq({ "great_customer" => "true" })
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '.message_customer' do
|
121
|
+
before do
|
122
|
+
SendSonar.configure do |config|
|
123
|
+
config.token = token
|
124
|
+
config.env = :local
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
let(:cassette_group) { "message_customer" }
|
129
|
+
let(:response) { SendSonar.message_customer(params) }
|
130
|
+
let(:token) { '3Z9L8xFjeNmXL7Yn-pFJUBoxkVWBbl5o' }
|
131
|
+
let(:params) do
|
132
|
+
{ :to => "5555555557", :text => "this is the message text" }
|
133
|
+
end
|
134
|
+
|
135
|
+
it_behaves_like "a mature, error handling gem"
|
136
|
+
|
137
|
+
context 'with invalid params' do
|
138
|
+
let(:params) do
|
139
|
+
{ :toz => "5555555558" }
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'raises a BadRequest error with hint' do
|
143
|
+
VCR.use_cassette("message_customer_bad_params") do
|
144
|
+
expect { response }.to raise_error(SendSonar::BadRequest,
|
145
|
+
'400 Bad Request: {"error":"text is missing, to is missing"}')
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'with proper params, active subscription' do
|
151
|
+
it 'returns a new customer' do
|
152
|
+
VCR.use_cassette('message_customer') do
|
153
|
+
expect(response).to be_a(SendSonar::Message)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'includes the expected attributes' do
|
158
|
+
VCR.use_cassette('message_customer') do
|
159
|
+
message = response
|
160
|
+
expect(message.to).to eq("5555555557")
|
161
|
+
expect(message.text).to eq("this is the message text")
|
162
|
+
expect(message.status).to eq("queued")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'send_sonar'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/customers
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: phone_number=5555555557&email=user%40example.com&first_name=john&last_name=doe&properties[great_customer]=true
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- 3Z9L8xFjeNmXL7Yn-pFJUBoxkVWBbl5o
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '110'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 201
|
27
|
+
message: 'Created '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '158'
|
33
|
+
Etag:
|
34
|
+
- '"f9adcdb012185fe56fe84ad04e1a2824"'
|
35
|
+
Cache-Control:
|
36
|
+
- max-age=0, private, must-revalidate
|
37
|
+
X-Request-Id:
|
38
|
+
- 68168308-eff1-41f8-98e0-12c2a4694f0f
|
39
|
+
X-Runtime:
|
40
|
+
- '0.490912'
|
41
|
+
Server:
|
42
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
43
|
+
Date:
|
44
|
+
- Fri, 19 Sep 2014 20:22:08 GMT
|
45
|
+
Connection:
|
46
|
+
- Keep-Alive
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"id":5,"phone_number":"5555555557","email":"user@example.com","first_name":"john","last_name":"doe","subscribed":true,"properties":{"great_customer":"true"}}'
|
50
|
+
http_version:
|
51
|
+
recorded_at: Fri, 19 Sep 2014 20:22:08 GMT
|
52
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/customers
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: phone_number=5555555557&email=user%40example.com&first_name=john&last_name=doe&properties[great_customer]=true
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- ts9mOO_O5Dc7TOBaEAQym-00RGEl3Uel
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '110'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 403
|
27
|
+
message: 'Forbidden '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '36'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 96abc3ba-c542-4609-b133-be2f649e8770
|
37
|
+
X-Runtime:
|
38
|
+
- '0.016683'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:22:08 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"Api Disabled For Company"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:22:08 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/customers
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: phone_numbah=5555555558
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- 3Z9L8xFjeNmXL7Yn-pFJUBoxkVWBbl5o
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '23'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 400
|
27
|
+
message: 'Bad Request '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '35'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- c8c9a1f9-4caa-419c-92f8-7a9d4a2729d6
|
37
|
+
X-Runtime:
|
38
|
+
- '0.017334'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:22:08 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"phone_number is missing"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:22:08 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/customers
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: phone_number=5555555557&email=user%40example.com&first_name=john&last_name=doe&properties[great_customer]=true
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- FAKE_TOKEN
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '110'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 401
|
27
|
+
message: 'Unauthorized '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '21'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 4138ab6a-357c-40a5-acb1-aa6370822cd3
|
37
|
+
X-Runtime:
|
38
|
+
- '0.012138'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:22:08 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"Bad Token"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:22:08 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/customers
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: phone_number=5555555557&email=user%40example.com&first_name=john&last_name=doe&properties[great_customer]=true
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- tKux9Vwkt0UuTVJqGUO80MGJHCAeebpe
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '110'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 403
|
27
|
+
message: 'Forbidden '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '34'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 60931c12-7335-48db-bf4c-5d15b0da874d
|
37
|
+
X-Runtime:
|
38
|
+
- '0.015270'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:22:08 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"No Active Subscription"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:22:08 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/messages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: to=5555555557&text=this%20is%20the%20message%20text
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- 3Z9L8xFjeNmXL7Yn-pFJUBoxkVWBbl5o
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '51'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 202
|
27
|
+
message: 'Accepted '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '71'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 77e091c0-f026-4e5d-b9d7-931990d73c95
|
37
|
+
X-Runtime:
|
38
|
+
- '0.057751'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:52:14 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"to":"5555555557","text":"this is the message text","status":"queued"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:52:14 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/messages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: to=5555555557&text=this%20is%20the%20message%20text
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- ts9mOO_O5Dc7TOBaEAQym-00RGEl3Uel
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '51'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 403
|
27
|
+
message: 'Forbidden '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '36'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 091f4623-a053-46fc-8680-3f2ea4a1ffbb
|
37
|
+
X-Runtime:
|
38
|
+
- '0.028476'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:48:59 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"Api Disabled For Company"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:48:59 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/messages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: toz=5555555558
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- 3Z9L8xFjeNmXL7Yn-pFJUBoxkVWBbl5o
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '14'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 400
|
27
|
+
message: 'Bad Request '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '42'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 9ce887cb-c076-43af-8400-04a3c0f44a02
|
37
|
+
X-Runtime:
|
38
|
+
- '0.023421'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:48:59 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"text is missing, to is missing"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:48:59 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/messages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: to=5555555557&text=this%20is%20the%20message%20text
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- FAKE_TOKEN
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '51'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 401
|
27
|
+
message: 'Unauthorized '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '21'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 0af8cfce-d329-49bc-b10e-a589b4d7f453
|
37
|
+
X-Runtime:
|
38
|
+
- '0.021898'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:48:59 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"Bad Token"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:48:59 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:3000/api/v1/messages
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: to=5555555557&text=this%20is%20the%20message%20text
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Token:
|
15
|
+
- tKux9Vwkt0UuTVJqGUO80MGJHCAeebpe
|
16
|
+
Client:
|
17
|
+
- rubygem 0.0.1
|
18
|
+
Content-Length:
|
19
|
+
- '51'
|
20
|
+
Content-Type:
|
21
|
+
- application/x-www-form-urlencoded
|
22
|
+
User-Agent:
|
23
|
+
- Ruby
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 403
|
27
|
+
message: 'Forbidden '
|
28
|
+
headers:
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '34'
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
X-Request-Id:
|
36
|
+
- 1c9f8477-1fcc-47e4-bc64-e18af44a95c7
|
37
|
+
X-Runtime:
|
38
|
+
- '0.110783'
|
39
|
+
Server:
|
40
|
+
- WEBrick/1.3.1 (Ruby/2.1.0/2013-12-25)
|
41
|
+
Date:
|
42
|
+
- Fri, 19 Sep 2014 20:48:59 GMT
|
43
|
+
Connection:
|
44
|
+
- Keep-Alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":"No Active Subscription"}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Fri, 19 Sep 2014 20:48:59 GMT
|
50
|
+
recorded_with: VCR 2.9.2
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: send_sonar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Gesimondo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rest-client
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- john@jmondo.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .travis.yml
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.ruby-18
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- RELEASE.md
|
111
|
+
- Rakefile
|
112
|
+
- lib/send_sonar.rb
|
113
|
+
- lib/send_sonar/client.rb
|
114
|
+
- lib/send_sonar/configuration.rb
|
115
|
+
- lib/send_sonar/endpoints.yml
|
116
|
+
- lib/send_sonar/exceptions.rb
|
117
|
+
- lib/send_sonar/version.rb
|
118
|
+
- send_sonar.gemspec
|
119
|
+
- spec/integrations/simple_desk_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/vcr_cassettes/add_customer.yml
|
122
|
+
- spec/vcr_cassettes/add_customer_api_disabled.yml
|
123
|
+
- spec/vcr_cassettes/add_customer_bad_params.yml
|
124
|
+
- spec/vcr_cassettes/add_customer_bad_token.yml
|
125
|
+
- spec/vcr_cassettes/add_customer_no_subscription.yml
|
126
|
+
- spec/vcr_cassettes/message_customer.yml
|
127
|
+
- spec/vcr_cassettes/message_customer_api_disabled.yml
|
128
|
+
- spec/vcr_cassettes/message_customer_bad_params.yml
|
129
|
+
- spec/vcr_cassettes/message_customer_bad_token.yml
|
130
|
+
- spec/vcr_cassettes/message_customer_no_subscription.yml
|
131
|
+
homepage: http://github.com/sendsonar/send_sonar_gem
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.2.1
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Provides a clean and simple gem to connect to Sonar
|
155
|
+
test_files:
|
156
|
+
- spec/integrations/simple_desk_spec.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
- spec/vcr_cassettes/add_customer.yml
|
159
|
+
- spec/vcr_cassettes/add_customer_api_disabled.yml
|
160
|
+
- spec/vcr_cassettes/add_customer_bad_params.yml
|
161
|
+
- spec/vcr_cassettes/add_customer_bad_token.yml
|
162
|
+
- spec/vcr_cassettes/add_customer_no_subscription.yml
|
163
|
+
- spec/vcr_cassettes/message_customer.yml
|
164
|
+
- spec/vcr_cassettes/message_customer_api_disabled.yml
|
165
|
+
- spec/vcr_cassettes/message_customer_bad_params.yml
|
166
|
+
- spec/vcr_cassettes/message_customer_bad_token.yml
|
167
|
+
- spec/vcr_cassettes/message_customer_no_subscription.yml
|
168
|
+
has_rdoc:
|