arcticelvis 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +25 -0
- data/LICENSE.txt +22 -0
- data/README.md +105 -0
- data/Rakefile +1 -0
- data/arcticelvis.gemspec +30 -0
- data/lib/arcticelvis.rb +22 -0
- data/lib/arcticelvis/base.rb +29 -0
- data/lib/arcticelvis/configuration.rb +26 -0
- data/lib/arcticelvis/event.rb +35 -0
- data/lib/arcticelvis/event_message.rb +11 -0
- data/lib/arcticelvis/request.rb +44 -0
- data/lib/arcticelvis/version.rb +3 -0
- data/spec/arcticelvis/arcticelvis_spec.rb +7 -0
- data/spec/arcticelvis/configuration_spec.rb +16 -0
- data/spec/arcticelvis/event_message_spec.rb +29 -0
- data/spec/arcticelvis/event_spec.rb +91 -0
- data/spec/arcticelvis/request_spec.rb +15 -0
- data/spec/fixtures/vcr_cassettes/event_200.yml +52 -0
- data/spec/fixtures/vcr_cassettes/event_404.yml +50 -0
- data/spec/fixtures/vcr_cassettes/event_message_preview_200.yml +170 -0
- data/spec/fixtures/vcr_cassettes/event_message_preview_404.yml +50 -0
- data/spec/fixtures/vcr_cassettes/event_trigger_404.yml +50 -0
- data/spec/fixtures/vcr_cassettes/event_trigger_success.yml +56 -0
- data/spec/fixtures/vcr_cassettes/request_4001.yml +50 -0
- data/spec/spec_helper.rb +12 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f984fab7a36ecb4ada90b650f43ed3318a1dce4c
|
4
|
+
data.tar.gz: 8a03ae8b11c92f1f73c92a9f59a23176322e0e89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9e56aad3247751eefca75dbd813f5c93dfa5a9a91e20bb4770d0325b761fefd16bb287da93973404535fb4e5244129865964d186386e437e3eb7a880bdd2287
|
7
|
+
data.tar.gz: fd4791255d89929a0871a3a2481f1e95732d265720354e1e55956b270db1d4cd266745333f8fd51274584c85312d37fa1db8c1bf3913911bb5508a8b60c806e1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
25
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 ArcticElvis AS
|
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,105 @@
|
|
1
|
+
# ArcticElvis
|
2
|
+
|
3
|
+
ArcticElvis is a fisherman from a long line of fishermen in the upmost arctic parts of Norway. He can help you get more fish - aka sell more. This is a ruby client for `api.arcticelvis.com`.
|
4
|
+
|
5
|
+
The API is documentet here: [http://docs.arcticelvis.apiary.io/](http://docs.arcticelvis.apiary.io/) (work in progress)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'arcticelvis'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install arcticelvis
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Configuration
|
24
|
+
|
25
|
+
Setup the API key. It can be found under the settings meny in the app.
|
26
|
+
|
27
|
+
```
|
28
|
+
Arcticelvis.configure do |config|
|
29
|
+
config.api_key = 'YOUR_API_KEY'
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
### Events
|
34
|
+
Events let you trigger event emails.
|
35
|
+
|
36
|
+
#### Trigger
|
37
|
+
|
38
|
+
```
|
39
|
+
event = Arcticelvis::Event.new(id: YOUR_EVENT_ID)
|
40
|
+
|
41
|
+
event.trigger({
|
42
|
+
to: 'email@example.com',
|
43
|
+
payload: {
|
44
|
+
name: "Bob roy",
|
45
|
+
personal_greeting: "Thanks for the signup Bob!",
|
46
|
+
favorite_colors: ['red', 'blue']
|
47
|
+
}
|
48
|
+
})
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
#### Find
|
53
|
+
Will lookup an event and all its messages
|
54
|
+
|
55
|
+
```
|
56
|
+
event = Arcticelvis::Event.find("EVENT_ID")
|
57
|
+
event.name #=> "New Signup"
|
58
|
+
event_message = event.event_messages[0]
|
59
|
+
event_message.state #=> "paused"
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
#### Preview event messages
|
65
|
+
TODO: make something like letter opener
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
event_message = Arcticelvis::EventMessage.new(id: EVENT_MESSAGE_ID, event_id: EVENT_ID)
|
70
|
+
event_message.preview({
|
71
|
+
payload: {
|
72
|
+
name: "ArcticElvis",
|
73
|
+
age: 98
|
74
|
+
}
|
75
|
+
})
|
76
|
+
|
77
|
+
#simplified preview output =>
|
78
|
+
"<html>…Thanks for the signup ArcticElvis, you are 98 years old. Really!?…</html>
|
79
|
+
|
80
|
+
```
|
81
|
+
|
82
|
+
you can also lookup an event and loop through its messages
|
83
|
+
|
84
|
+
```
|
85
|
+
event = Arcticelvis::Event.find("EVENT_ID")
|
86
|
+
event_message = event.event_messages.first
|
87
|
+
event_message.preview({
|
88
|
+
payload: {
|
89
|
+
name: "ArcticElvis",
|
90
|
+
age: 98
|
91
|
+
}
|
92
|
+
})
|
93
|
+
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
## Contributing
|
100
|
+
|
101
|
+
1. Fork it ( http://github.com/arcticelvis/arcticelvis-ruby/fork )
|
102
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
103
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
104
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
105
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/arcticelvis.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'arcticelvis/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "arcticelvis"
|
8
|
+
spec.version = Arcticelvis::VERSION
|
9
|
+
spec.authors = ["Christian Hager"]
|
10
|
+
spec.email = ["persson.hager@gmail.com"]
|
11
|
+
spec.summary = %q{A client for the ArcticElvis API}
|
12
|
+
spec.description = %q{ArcticElvis will help you get more fish, aka sell more. This is a fishing pole.}
|
13
|
+
spec.homepage = "https://github.com/arcticelvis/arcticelvis-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_dependency "faraday", "~> 0.8.8"
|
22
|
+
spec.add_dependency "json", "~> 1.8.1"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "guard"
|
28
|
+
spec.add_development_dependency "vcr", "~> 2.8.0"
|
29
|
+
spec.add_development_dependency "webmock"
|
30
|
+
end
|
data/lib/arcticelvis.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "arcticelvis/version"
|
2
|
+
require "arcticelvis/configuration"
|
3
|
+
require "arcticelvis/request"
|
4
|
+
require "arcticelvis/base"
|
5
|
+
require "arcticelvis/event"
|
6
|
+
require "arcticelvis/event_message"
|
7
|
+
|
8
|
+
|
9
|
+
module Arcticelvis
|
10
|
+
extend Configuration
|
11
|
+
|
12
|
+
class ArcticelvisError < StandardError; end
|
13
|
+
class AuthenticationError < ArcticelvisError; end
|
14
|
+
class InvalidOptionsError < ArcticelvisError; end
|
15
|
+
class RecordNotFoundError < ArcticelvisError; end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def request(http_method, api_url, data)
|
19
|
+
Request.new(http_method, api_url, data).perform
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Arcticelvis
|
2
|
+
class Base
|
3
|
+
|
4
|
+
attr_accessor :created_at, :updated_at
|
5
|
+
|
6
|
+
# Initializes the object using the given attributes
|
7
|
+
#
|
8
|
+
# @param [Hash] attributes The attributes to use for initialization
|
9
|
+
def initialize(attributes = {})
|
10
|
+
set_attributes(attributes)
|
11
|
+
parse_timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
# Sets the attributes
|
15
|
+
#
|
16
|
+
# @param [Hash] attributes The attributes to initialize
|
17
|
+
def set_attributes(attributes)
|
18
|
+
attributes.each_pair do |key, value|
|
19
|
+
instance_variable_set("@#{key}", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Parses UNIX timestamps and creates Time objects.
|
24
|
+
def parse_timestamps
|
25
|
+
@created_at = DateTime.parse(created_at) if created_at
|
26
|
+
@updated_at = DateTime.parse(updated_at) if updated_at
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Arcticelvis
|
2
|
+
module Configuration
|
3
|
+
VALID_CONFIG_KEYS = [:api_key].freeze
|
4
|
+
DEFAULT_API_KEY = nil
|
5
|
+
API_HOST = "http://api.arcticelvis.com"
|
6
|
+
|
7
|
+
attr_accessor *VALID_CONFIG_KEYS
|
8
|
+
|
9
|
+
# setup defaults on extend
|
10
|
+
def self.extended(base)
|
11
|
+
base.reset
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset
|
15
|
+
self.api_key = DEFAULT_API_KEY
|
16
|
+
end
|
17
|
+
|
18
|
+
def configure
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
def options
|
23
|
+
Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Arcticelvis
|
2
|
+
class Event < Base
|
3
|
+
attr_accessor :id, :name, :event_messages
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def find(id)
|
7
|
+
response, status = Arcticelvis.request(:get, "events/#{id}", {})
|
8
|
+
raise RecordNotFoundError if status == 404
|
9
|
+
|
10
|
+
event_messages = response["event"]["event_messages"]
|
11
|
+
response["event"].delete("event_messages")
|
12
|
+
event = self.new(response["event"])
|
13
|
+
|
14
|
+
if event_messages
|
15
|
+
res = []
|
16
|
+
event_messages.each do |event_message|
|
17
|
+
res << Arcticelvis::EventMessage.new(event_message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
event.event_messages = res if res
|
21
|
+
event
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def trigger(options={})
|
26
|
+
raise InvalidOptionsError.new("no email given") unless options[:to]
|
27
|
+
response, status = Arcticelvis.request(:post, "events/#{id}/trigger", options)
|
28
|
+
raise RecordNotFoundError if status == 404
|
29
|
+
if status == 201
|
30
|
+
set_attributes(response["event_instance"]["event"])
|
31
|
+
return self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Arcticelvis
|
2
|
+
class EventMessage < Base
|
3
|
+
attr_accessor :id, :event_id, :subject, :preview, :state
|
4
|
+
|
5
|
+
def preview(payload={})
|
6
|
+
response, status = Arcticelvis.request(:post, "events/#{event_id}/event_messages/#{id}/preview", payload)
|
7
|
+
raise Arcticelvis::RecordNotFoundError if status == 404
|
8
|
+
response["event_message"]["preview"]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
module Arcticelvis
|
4
|
+
class Request
|
5
|
+
|
6
|
+
def initialize(http_method, api_url, data)
|
7
|
+
raise Arcticelvis::AuthenticationError if Arcticelvis.api_key.nil?
|
8
|
+
@conn = Faraday.new(url: Arcticelvis::Configuration::API_HOST)
|
9
|
+
@api_url = api_url
|
10
|
+
@data = data
|
11
|
+
@http_method = http_method
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform
|
15
|
+
case @http_method
|
16
|
+
when :get
|
17
|
+
response = @conn.get do |req|
|
18
|
+
req.url "/api/v2/#{@api_url}.json"
|
19
|
+
req.headers['Content-Type'] = 'application/json'
|
20
|
+
req.headers['Authorization'] = "Token token=#{Arcticelvis.api_key}"
|
21
|
+
end
|
22
|
+
|
23
|
+
when :post
|
24
|
+
response = @conn.post do |req|
|
25
|
+
req.url "/api/v2/#{@api_url}.json"
|
26
|
+
req.headers['Content-Type'] = 'application/json'
|
27
|
+
req.headers['Authorization'] = "Token token=#{Arcticelvis.api_key}"
|
28
|
+
req.body = @data.to_json
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if response.body.to_s.include? 'Access denied'
|
33
|
+
raise Arcticelvis::AuthenticationError.new("Invalid credentials, is your API KEY correct?")
|
34
|
+
else
|
35
|
+
result = JSON.parse(response.body)
|
36
|
+
if result["error"] && result["error"]["id"] == 4001
|
37
|
+
raise Arcticelvis::AuthenticationError.new("Invalid API KEY")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
return result, response.status.to_i
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ".api_key" do
|
4
|
+
it "should have a key" do
|
5
|
+
Arcticelvis.api_key.should eq Arcticelvis::Configuration::DEFAULT_API_KEY
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '.configure' do
|
10
|
+
it "should set the api_key" do
|
11
|
+
Arcticelvis.configure do |config|
|
12
|
+
config.api_key = "123"
|
13
|
+
Arcticelvis.api_key.should eq "123"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Arcticelvis::EventMessage do
|
4
|
+
before do
|
5
|
+
Arcticelvis.configure do |config|
|
6
|
+
config.api_key = 'cd242fb288ddf6e501decb92b84ac0a4'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "preview" do
|
11
|
+
describe "failure" do
|
12
|
+
it "raises record not found exception if the event message is not found" do
|
13
|
+
VCR.use_cassette('event_message_preview_404') do
|
14
|
+
event_message = Arcticelvis::EventMessage.new({id: "2", event_id: "1"})
|
15
|
+
expect { event_message.preview }.to raise_exception Arcticelvis::RecordNotFoundError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "success" do
|
21
|
+
it "should render the payload in the event message and return a preview" do
|
22
|
+
VCR.use_cassette('event_message_preview_200') do
|
23
|
+
event_message = Arcticelvis::EventMessage.new({id: "235", event_id: "177"})
|
24
|
+
event_message.preview({payload: {name: 'Surly you have a name mister!'}}).should include "Surly you have a name mister!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Arcticelvis::Event do
|
4
|
+
before do
|
5
|
+
Arcticelvis.configure do |config|
|
6
|
+
config.api_key = 'abc'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
describe ".find" do
|
12
|
+
|
13
|
+
describe "failure" do
|
14
|
+
it "should raise RecordNotFoundError when no event is found" do
|
15
|
+
VCR.use_cassette('event_404') do
|
16
|
+
expect {Arcticelvis::Event.find("123")}.to raise_exception Arcticelvis::RecordNotFoundError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "success" do
|
22
|
+
around(:each) do |example|
|
23
|
+
VCR.use_cassette('event_200') do
|
24
|
+
example.run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "makes a GET request to the api-endpoint to fetch a specific event" do
|
29
|
+
event = Arcticelvis::Event.find("177")
|
30
|
+
event.should be_a(Arcticelvis::Event)
|
31
|
+
event.name.should eq "New user"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "gives you an array of event messages" do
|
35
|
+
event = Arcticelvis::Event.find("177")
|
36
|
+
event.event_messages[0].should be_a(Arcticelvis::EventMessage)
|
37
|
+
event.event_messages[0].subject.should eq "Welcome"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
describe ".trigger" do
|
43
|
+
describe "failure" do
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "success" do
|
47
|
+
around(:each) do |example|
|
48
|
+
VCR.use_cassette('event_trigger_success') do
|
49
|
+
example.run
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "makes a POST request to the api-endpoint to trigger an event and loads the event" do
|
54
|
+
event = Arcticelvis::Event.new(id: '177')
|
55
|
+
|
56
|
+
expect{
|
57
|
+
event.trigger({
|
58
|
+
to: 'ch@skalar.no',
|
59
|
+
payload: {
|
60
|
+
name: "Arctic"
|
61
|
+
}
|
62
|
+
})
|
63
|
+
}.to change{
|
64
|
+
event.name
|
65
|
+
}.from(nil).to("New user")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "failure" do
|
70
|
+
it "raises exception if the event is not found" do
|
71
|
+
VCR.use_cassette('event_trigger_404') do
|
72
|
+
event = Arcticelvis::Event.new(id: '1')
|
73
|
+
|
74
|
+
expect{
|
75
|
+
event.trigger({
|
76
|
+
to: 'ch@skalar.no',
|
77
|
+
payload: {
|
78
|
+
name: "Arctic"
|
79
|
+
}
|
80
|
+
})
|
81
|
+
}.to raise_exception Arcticelvis::RecordNotFoundError
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it "raises exception if the event is paused" do
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Arcticelvis::Request do
|
4
|
+
|
5
|
+
describe "failure" do
|
6
|
+
it "should raise ArcticElvis::AuthenticationError if invalid key" do
|
7
|
+
VCR.use_cassette('request_4001') do
|
8
|
+
expect{
|
9
|
+
Arcticelvis::Request.new(:post, "/events/1/trigger", {}).perform
|
10
|
+
}.to raise_exception Arcticelvis::AuthenticationError
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/177.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=cd242fb288ddf6e501decb92b84ac0a4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- must-revalidate, private, max-age=0
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 20:18:58 GMT
|
31
|
+
Etag:
|
32
|
+
- '"c186ce12ec597392a98351e0dad5f986"'
|
33
|
+
Status:
|
34
|
+
- 200 OK
|
35
|
+
X-Rack-Cache:
|
36
|
+
- miss
|
37
|
+
X-Request-Id:
|
38
|
+
- 6ec52c04895889ab6d3de191e7b98e82
|
39
|
+
X-Runtime:
|
40
|
+
- '0.422020'
|
41
|
+
X-Ua-Compatible:
|
42
|
+
- IE=Edge,chrome=1
|
43
|
+
Transfer-Encoding:
|
44
|
+
- chunked
|
45
|
+
Connection:
|
46
|
+
- keep-alive
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"event":{"id":177,"name":"New user","state":"active","created_at":"2014-01-08T18:59:15Z","updated_at":"2014-01-08T19:00:11Z","event_messages":[{"id":235,"subject":"Welcome","created_at":"2014-01-08T19:00:02Z","updated_at":"2014-01-08T19:00:18Z","state":"active","preview":false}]}}'
|
50
|
+
http_version:
|
51
|
+
recorded_at: Wed, 08 Jan 2014 20:18:58 GMT
|
52
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/123.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=cd242fb288ddf6e501decb92b84ac0a4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- no-cache, private
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 20:15:49 GMT
|
31
|
+
Status:
|
32
|
+
- 404 Not Found
|
33
|
+
X-Rack-Cache:
|
34
|
+
- miss
|
35
|
+
X-Request-Id:
|
36
|
+
- cf64b768a923e64b1bc27e98d4cde404
|
37
|
+
X-Runtime:
|
38
|
+
- '0.012949'
|
39
|
+
X-Ua-Compatible:
|
40
|
+
- IE=Edge,chrome=1
|
41
|
+
Transfer-Encoding:
|
42
|
+
- chunked
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":{"id":404,"message":"Could not find event with id 123"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Wed, 08 Jan 2014 20:15:49 GMT
|
50
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,170 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/177/event_messages/235/preview.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"payload":{"name":"Surly you have a name mister!"}}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=cd242fb288ddf6e501decb92b84ac0a4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- max-age=0, private, must-revalidate
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 21:39:56 GMT
|
31
|
+
Etag:
|
32
|
+
- '"3c093cb355b77b5ce74223dafad4ef78"'
|
33
|
+
Location:
|
34
|
+
- /api/v2/events.177
|
35
|
+
Status:
|
36
|
+
- 201 Created
|
37
|
+
X-Rack-Cache:
|
38
|
+
- invalidate, pass
|
39
|
+
X-Request-Id:
|
40
|
+
- 0bf86190274968c1af80bfd5465f083d
|
41
|
+
X-Runtime:
|
42
|
+
- '0.291256'
|
43
|
+
X-Ua-Compatible:
|
44
|
+
- IE=Edge,chrome=1
|
45
|
+
Transfer-Encoding:
|
46
|
+
- chunked
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"event_message":{"id":235,"subject":"Welcome","created_at":"2014-01-08T19:00:02Z","updated_at":"2014-01-08T20:50:54Z","state":"active","preview":"<!DOCTYPE
|
52
|
+
HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n <html>\n <head>\n <meta
|
53
|
+
http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta
|
54
|
+
name=\"viewport\" content=\"width=device-width\" />\n <meta charset=\"utf-8\">\n <title></title>\n </head>\n <body>\n <style
|
55
|
+
type=\"text/css\">\n /* Client-specific Styles */\n #outlook
|
56
|
+
a {padding:0;} /* Force Outlook to provide a \"view in browser\" menu link.
|
57
|
+
*/\n body{width:100% !important; -webkit-text-size-adjust:100%;
|
58
|
+
-ms-text-size-adjust:100%; margin:0; padding:0;} \n /* Prevent
|
59
|
+
Webkit and Windows Mobile platforms from changing default font sizes.*/ \n .ExternalClass
|
60
|
+
{width:100%;} /* Force Hotmail to display emails at full width */ \n .ExternalClass,
|
61
|
+
.ExternalClass span, .ExternalClass td, .ExternalClass * {line-height: 100%;}\n /*
|
62
|
+
Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/
|
63
|
+
*/ \n #backgroundTable {margin:0; padding:0; width:100% !important;
|
64
|
+
line-height: 100% !important;}\n /* End reset */\n /*
|
65
|
+
Some sensible defaults for images, Bring inline: Yes. */\n img
|
66
|
+
{outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;} \n a
|
67
|
+
img {border:none;} \n .image_fix {display:block;}\n /*
|
68
|
+
Outlook 07, 10 Padding issue fix, Bring inline: No.*/\n table td
|
69
|
+
{border-collapse: collapse;}\n @media only screen and (max-width:
|
70
|
+
620px) {\n .inner-wrapper{width: 320px;}\n .collaps-on-phone,
|
71
|
+
td.collaps-on-phone{width: 0px; height: 0px; display:none;}\n }\n @-webkit-viewport{width:device-width}\n @-moz-viewport{width:device-width}\n @-ms-viewport{width:device-width}\n @-o-viewport{width:device-width}\n @viewport{width:device-width}\n\n </style>\n <style
|
72
|
+
type=\"text/css\">table#nl_background {font-family:Arial, Helvetica, sans-serif;
|
73
|
+
font-size:12px; margin:0px;background:#e7e8e8;}\r\ntable#nl_content {font-family:Arial,
|
74
|
+
Helvetica, sans-serif; font-size:12px; margin:0px;background:#fff;}\r\nh1
|
75
|
+
{ !important; margin: 0px; font-weight: normal; font-size: 26px; line-height:26px;
|
76
|
+
font-family: arial,verdana,helvetica; color:#000000;text-decoration:none;}\r\nh2
|
77
|
+
{ !important; margin: 0px; font-weight: normal; font-size: 20px; line-height:20px;
|
78
|
+
font-family: arial,verdana,helvetica; color:#000000;text-decoration:none;}\r\nh3
|
79
|
+
{ !important; margin: 0px; font-weight: normal; font-size: 18px; line-height:20px;
|
80
|
+
font-family: arial,verdana,helvetica; color:#000000;text-decoration:none;}\r\nh4
|
81
|
+
{ !important; margin: 0px; font-weight: normal; font-size: 18px; line-height:20px;
|
82
|
+
font-family: arial,verdana,helvetica; color:#000000;text-decoration:none;}\r\nh1
|
83
|
+
a, h2 a, h3 a, h4 a{color:#000000;text-decoration:none;}\r\np, div { font-size:
|
84
|
+
12px; line-height: 16px; font-family: arial,verdana,helvetica; color: #555;
|
85
|
+
margin: 0px; }\r\n.divP { font-size: 12px; line-height: 16px; font-family:
|
86
|
+
arial,verdana,helvetica; color: #555; margin: 0px; }\r\na { color: #0caad1;
|
87
|
+
text-decoration: none; }\r\n.signature{ font-weight:bold; color: #999999;}\r\n.easy{color:#999999;}\r\nimg
|
88
|
+
{display:block;}\r\n.headerFullBanner{width:600px;}\r\n.headerPaddedbanner{width:540px;}\r\n.imgBanner{width:540px;}\r\n.imgLeft{width:260px;}\r\n.imgRight{width:260px;}\r\n.imgDouble{width:260px;}\r\n.imgTriple{width:170px;}\r\n.imgCart{max-width:122px;}</style><!--Elvis
|
89
|
+
3.0 Framework-->\n<!--Background Table-->\n<table width=\"100%\" cellspacing=\"0\"
|
90
|
+
cellpadding=\"0\" border=\"0\" align=\"center\" id=\"nl_background\" style=\"background:
|
91
|
+
#ffffff;font-family:Arial, Helvetica, sans-serif;font-size:12px;margin:0px;\"><tbody><tr>\n<td>
|
92
|
+
\n \t<!--email container-->\n <table cellspacing=\"0\" cellpadding=\"0\"
|
93
|
+
border=\"0\" align=\"center\" width=\"600\"><tbody>\n<tr>\n<td width=\"600\">\n <!--Pre
|
94
|
+
header-->\n <table cellspacing=\"0\" cellpadding=\"0\"
|
95
|
+
border=\"0\" width=\"600\" id=\"nl_outerheader\"><tbody><tr>\n<td valign=\"middle\"
|
96
|
+
width=\"400\" align=\"left\" height=\"30\">\n <div
|
97
|
+
class=\"editable\" style=\"font-size: 12px; line-height: 16px; font-family:
|
98
|
+
arial,verdana,helvetica; color: #555; margin: 0px;\">\n<p style=\"font-size:
|
99
|
+
12px; line-height: 16px; font-family: arial,verdana,helvetica; color: #555;
|
100
|
+
margin: 0px;\">Arct</p>\n</div>\n </td>\n <td
|
101
|
+
valign=\"middle\" width=\"200\" align=\"right\" height=\"30\">\n \t<p
|
102
|
+
style=\"font-size: 12px; line-height: 16px; font-family: arial,verdana,helvetica;
|
103
|
+
color: #555; margin: 0px;\"><a href=\"\" class=\"text_only show_online_link\"
|
104
|
+
style=\"color: #2890ab;text-decoration:none;\">View in browser</a></p>\n </td>\n </tr></tbody></table>\n<!--End
|
105
|
+
pre header-->\n</td>\n </tr>\n<tr>\n<td width=\"600\"> \n <!--content
|
106
|
+
container-->\n <table cellspacing=\"0\" cellpadding=\"0\"
|
107
|
+
border=\"0\" width=\"600\" bgcolor=\"#FFFFFF\" id=\"nl_content\" style=\"background:
|
108
|
+
#2890ab;font-family:Arial, Helvetica, sans-serif;font-size:12px;margin:0px;\"><tbody>\n<tr>\n<td
|
109
|
+
width=\"600\">\n \t<!--Header-->\n \t<table
|
110
|
+
cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" id=\"header\"><tbody
|
111
|
+
class=\"nl_column nl_header_column\" default_articles=\"banner\"><tr class=\"nl_row\"><td
|
112
|
+
class=\"nl_cell\" cid=\"c79\" title=\"\">\n<a href=\"http://www.arcticelvis.no\"
|
113
|
+
class=\"nl_wrapped_link image_wrap\" ae_link_id=\"67601\" style=\"color: #eccf04;text-decoration:none;\"><img
|
114
|
+
src=\"http://res.cloudinary.com/arcticelvis/image/upload/c_scale,w_600/v1351192682/xqqdk00lzpethjmfq9t2.jpg\"
|
115
|
+
class=\"headerFullBanner\" alt=\"Rorbu Confessions\" width=\"600\" height=\"326\"
|
116
|
+
style=\"display: block;width:600px;\"></a><table width=\"600\" cellspacing=\"0\"
|
117
|
+
cellpadding=\"0\" border=\"0\"><tbody>\n<tr></tr>\n<tr>\n<td width=\"600\"
|
118
|
+
height=\"30\"></td>\n\t</tr>\n</tbody></table>\n</td></tr></tbody></table>\n<!--End
|
119
|
+
header-->\n</td>\n </tr>\n<tr>\n<td width=\"600\">\n \t<table
|
120
|
+
width=\"600\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody><tr>\n<td
|
121
|
+
width=\"30\"></td>\n <td width=\"540\">\n \t<table
|
122
|
+
cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"540\"><tbody class=\"nl_column
|
123
|
+
nl_article_column\" default_articles=\"article triple_article_with_images\"><tr
|
124
|
+
class=\"nl_row\" style=\"\"><td class=\"nl_cell\" cid=\"c80\" title=\"\"><table
|
125
|
+
width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tbody>\n<tr>\n<td
|
126
|
+
width=\"100%\" valign=\"top\" align=\"left\">\n \t<div class=\"editable\"
|
127
|
+
style=\"font-size: 12px; line-height: 16px; font-family: arial,verdana,helvetica;
|
128
|
+
color: #555; margin: 0px;\"><p style=\"color: #ffffff;font-size:12px;line-height:16px;font-family:arial,verdana,helvetica;margin:0px;\">Welcome
|
129
|
+
Surly you have a name mister!!<br><br>You are now a very special person!</p></div>\n </td>\n </tr>\n<tr><td
|
130
|
+
width=\"100%\" class=\"nl_space\" height=\"40\"></td></tr>\n</tbody></table></td></tr></tbody></table>\n</td>\n <td
|
131
|
+
width=\"30\"></td>\n \t</tr></tbody></table>\n</td>\n </tr>\n<tr>\n<td
|
132
|
+
width=\"600\">\n \t<!--Footer-->\n \t<!--Header-->\n \t<table
|
133
|
+
cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"600\" id=\"footer\"><tbody
|
134
|
+
class=\"nl_column nl_footer_column\" default_articles=\"semi_advanced\"></tbody></table>\n<!--End
|
135
|
+
header--><!--End footer-->\n</td>\n </tr>\n</tbody></table>\n<!--End
|
136
|
+
content container-->\n</td>\n \t</tr>\n<tr>\n<td width=\"600\">\n <!--Outer
|
137
|
+
footer--> \n <table cellspacing=\"0\" cellpadding=\"0\"
|
138
|
+
border=\"0\" width=\"600\" id=\"nl_outerfooter\"><tbody>\n<tr>\n<td width=\"600\"
|
139
|
+
height=\"15\"></td>\n </tr>\n<tr>\n<td width=\"600\"
|
140
|
+
align=\"center\" height=\"30\" valign=\"middle\">\n \t<p
|
141
|
+
style=\"font-size: 12px; line-height: 16px; font-family: arial,verdana,helvetica;
|
142
|
+
color: #555; margin: 0px;\"><a href=\"\" class=\"text_only unsubscribe_link\"
|
143
|
+
style=\"color: #2890ab;text-decoration:none;\">Unsubscribe from this newsletter</a></p>\n </td>\n </tr>\n<tr>\n<td
|
144
|
+
width=\"600\" height=\"5\"></td>\n </tr>\n<tr>\n<td
|
145
|
+
width=\"600\" align=\"center\">\n \t<div class=\"easy
|
146
|
+
editable\" style=\"font-size: 12px; line-height: 16px; font-family: arial,verdana,helvetica;
|
147
|
+
color: #555; margin: 0px;\"><p style=\"font-size: 12px; line-height: 16px;
|
148
|
+
font-family: arial,verdana,helvetica; color: #555; margin: 0px;\">This newsletter
|
149
|
+
is sent to you because you signed up to our mailinglist last christmas.</p></div>\n </td>\n </tr>\n<tr></tr>\n<tr>\n<td
|
150
|
+
width=\"600\" height=\"5\"></td>\n </tr>\n<tr>\n<td
|
151
|
+
width=\"600\" align=\"center\">\n\n\t\t\t\t\t\t\t\t\t\t\n \t<p
|
152
|
+
class=\"signature uneditable\" style=\"font-size: 12px; line-height: 16px;
|
153
|
+
font-family: arial,verdana,helvetica; color: #555; margin: 0px;font-weight:bold;\">\n\t\t\t\t\t\t\t\t\t\t</p>\n<p
|
154
|
+
style=\"font-size: 12px; line-height: 16px; font-family: arial,verdana,helvetica;
|
155
|
+
color: #555; margin: 0px;\">\n\t\t\t\t\t\t\t\t\t\t<a class=\"aehts\" rel=\"sys\"
|
156
|
+
href=\"http://www.arcticelvis.com?source=nl_snesquatter56\" style=\"color:
|
157
|
+
#2890ab;text-decoration:none;\">Powered by ArcticElvis</a>\n\t\t\t\t\t\t\t\t\t\t</p>\n \t\t<p
|
158
|
+
class=\"easy\" style=\"font-size: 12px; line-height: 16px; font-family: arial,verdana,helvetica;
|
159
|
+
color: #555; margin: 0px;\"></p>\n<div class=\"editable\" style=\"font-size:
|
160
|
+
12px; line-height: 16px; font-family: arial,verdana,helvetica; color: #555;
|
161
|
+
margin: 0px;\">Global king of simple newsletters.</div>\n<p style=\"font-size:
|
162
|
+
12px; line-height: 16px; font-family: arial,verdana,helvetica; color: #555;
|
163
|
+
margin: 0px;\"></p>\n\t\t\t\t\t\t\t\t\t<p style=\"font-size: 12px; line-height:
|
164
|
+
16px; font-family: arial,verdana,helvetica; color: #555; margin: 0px;\"></p>\n </td>\n </tr>\n<tr>\n<td
|
165
|
+
width=\"600\" height=\"30\"></td>\n </tr>\n</tbody></table>\n<!--End
|
166
|
+
outer footer -->\n</td>\n </tr>\n<tr>\n<td width=\"600\" height=\"30\"></td>\n </tr>\n</tbody></table>\n</td>\n </tr></tbody></table><!--End
|
167
|
+
Background Table--></body>\n </html>"}}'
|
168
|
+
http_version:
|
169
|
+
recorded_at: Wed, 08 Jan 2014 21:39:56 GMT
|
170
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/1/event_messages/2/preview.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=cd242fb288ddf6e501decb92b84ac0a4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- no-cache
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 21:29:15 GMT
|
31
|
+
Status:
|
32
|
+
- 404 Not Found
|
33
|
+
X-Rack-Cache:
|
34
|
+
- invalidate, pass
|
35
|
+
X-Request-Id:
|
36
|
+
- 4b7d04388d16f356d9b82acedaad77d6
|
37
|
+
X-Runtime:
|
38
|
+
- '0.114215'
|
39
|
+
X-Ua-Compatible:
|
40
|
+
- IE=Edge,chrome=1
|
41
|
+
Transfer-Encoding:
|
42
|
+
- chunked
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":{"id":404,"message":"Could not find event with id 1"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Wed, 08 Jan 2014 21:29:15 GMT
|
50
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/1/trigger.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"to":"ch@skalar.no","payload":{"name":"Arctic"}}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=cd242fb288ddf6e501decb92b84ac0a4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 404
|
23
|
+
message: Not Found
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- no-cache
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 21:08:36 GMT
|
31
|
+
Status:
|
32
|
+
- 404 Not Found
|
33
|
+
X-Rack-Cache:
|
34
|
+
- invalidate, pass
|
35
|
+
X-Request-Id:
|
36
|
+
- 416da34c22fa6e67cfcd411732c66506
|
37
|
+
X-Runtime:
|
38
|
+
- '0.133511'
|
39
|
+
X-Ua-Compatible:
|
40
|
+
- IE=Edge,chrome=1
|
41
|
+
Transfer-Encoding:
|
42
|
+
- chunked
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":{"id":404,"message":"Could not find event with id 1"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Wed, 08 Jan 2014 21:08:36 GMT
|
50
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/177/trigger.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"to":"ch@skalar.no","payload":{"name":"Arctic"}}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=cd242fb288ddf6e501decb92b84ac0a4
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- max-age=0, private, must-revalidate
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 20:50:51 GMT
|
31
|
+
Etag:
|
32
|
+
- '"cf914ee433791f30ea4a9685d6baab2d"'
|
33
|
+
Location:
|
34
|
+
- /api/v2/events.177
|
35
|
+
Status:
|
36
|
+
- 201 Created
|
37
|
+
X-Rack-Cache:
|
38
|
+
- invalidate, pass
|
39
|
+
X-Request-Id:
|
40
|
+
- c0e73b03db097fd334290bb286e88646
|
41
|
+
X-Runtime:
|
42
|
+
- '0.225595'
|
43
|
+
X-Ua-Compatible:
|
44
|
+
- IE=Edge,chrome=1
|
45
|
+
Transfer-Encoding:
|
46
|
+
- chunked
|
47
|
+
Connection:
|
48
|
+
- keep-alive
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"event_instance":{"subscriber":{"id":202009,"email":"ch@skalar.no","first_name":"Christian","last_name":"","unsubscribed":false,"bounced":false,"tracked":true,"created_at":"2013-06-15T10:23:49Z","data":{},"lists":[{"id":616,"name":"All","created_at":"2013-12-17T01:32:32Z","subscriber_count":83},{"id":432,"name":"Skalar
|
52
|
+
AS","created_at":"2013-06-15T10:17:01Z","subscriber_count":15}]},"event":{"id":177,"name":"New
|
53
|
+
user","state":"active","created_at":"2014-01-08T18:59:15Z","updated_at":"2014-01-08T19:00:11Z","event_messages":[{"id":235,"subject":"Welcome","created_at":"2014-01-08T19:00:02Z","updated_at":"2014-01-08T20:39:14Z","state":"active","preview":false}]}}}'
|
54
|
+
http_version:
|
55
|
+
recorded_at: Wed, 08 Jan 2014 20:50:51 GMT
|
56
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.arcticelvis.com/api/v2/events/1/trigger.json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Content-Type:
|
13
|
+
- application/json
|
14
|
+
Authorization:
|
15
|
+
- Token token=abc
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- '*/*'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 401
|
23
|
+
message: Unauthorized
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- no-cache
|
27
|
+
Content-Type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
Date:
|
30
|
+
- Wed, 08 Jan 2014 21:42:59 GMT
|
31
|
+
Status:
|
32
|
+
- 401 Unauthorized
|
33
|
+
X-Rack-Cache:
|
34
|
+
- invalidate, pass
|
35
|
+
X-Request-Id:
|
36
|
+
- 2c492e7c254d13d676711e1e0bc6d996
|
37
|
+
X-Runtime:
|
38
|
+
- '0.108615'
|
39
|
+
X-Ua-Compatible:
|
40
|
+
- IE=Edge,chrome=1
|
41
|
+
Transfer-Encoding:
|
42
|
+
- chunked
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"error":{"id":4001,"message":"Public access token is invalid"}}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Wed, 08 Jan 2014 21:43:00 GMT
|
50
|
+
recorded_with: VCR 2.8.0
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arcticelvis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Hager
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.8.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.8.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: ArcticElvis will help you get more fish, aka sell more. This is a fishing
|
126
|
+
pole.
|
127
|
+
email:
|
128
|
+
- persson.hager@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- Gemfile
|
135
|
+
- Guardfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- arcticelvis.gemspec
|
140
|
+
- lib/arcticelvis.rb
|
141
|
+
- lib/arcticelvis/base.rb
|
142
|
+
- lib/arcticelvis/configuration.rb
|
143
|
+
- lib/arcticelvis/event.rb
|
144
|
+
- lib/arcticelvis/event_message.rb
|
145
|
+
- lib/arcticelvis/request.rb
|
146
|
+
- lib/arcticelvis/version.rb
|
147
|
+
- spec/arcticelvis/arcticelvis_spec.rb
|
148
|
+
- spec/arcticelvis/configuration_spec.rb
|
149
|
+
- spec/arcticelvis/event_message_spec.rb
|
150
|
+
- spec/arcticelvis/event_spec.rb
|
151
|
+
- spec/arcticelvis/request_spec.rb
|
152
|
+
- spec/fixtures/vcr_cassettes/event_200.yml
|
153
|
+
- spec/fixtures/vcr_cassettes/event_404.yml
|
154
|
+
- spec/fixtures/vcr_cassettes/event_message_preview_200.yml
|
155
|
+
- spec/fixtures/vcr_cassettes/event_message_preview_404.yml
|
156
|
+
- spec/fixtures/vcr_cassettes/event_trigger_404.yml
|
157
|
+
- spec/fixtures/vcr_cassettes/event_trigger_success.yml
|
158
|
+
- spec/fixtures/vcr_cassettes/request_4001.yml
|
159
|
+
- spec/spec_helper.rb
|
160
|
+
homepage: https://github.com/arcticelvis/arcticelvis-ruby
|
161
|
+
licenses:
|
162
|
+
- MIT
|
163
|
+
metadata: {}
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubyforge_project:
|
180
|
+
rubygems_version: 2.0.14
|
181
|
+
signing_key:
|
182
|
+
specification_version: 4
|
183
|
+
summary: A client for the ArcticElvis API
|
184
|
+
test_files:
|
185
|
+
- spec/arcticelvis/arcticelvis_spec.rb
|
186
|
+
- spec/arcticelvis/configuration_spec.rb
|
187
|
+
- spec/arcticelvis/event_message_spec.rb
|
188
|
+
- spec/arcticelvis/event_spec.rb
|
189
|
+
- spec/arcticelvis/request_spec.rb
|
190
|
+
- spec/fixtures/vcr_cassettes/event_200.yml
|
191
|
+
- spec/fixtures/vcr_cassettes/event_404.yml
|
192
|
+
- spec/fixtures/vcr_cassettes/event_message_preview_200.yml
|
193
|
+
- spec/fixtures/vcr_cassettes/event_message_preview_404.yml
|
194
|
+
- spec/fixtures/vcr_cassettes/event_trigger_404.yml
|
195
|
+
- spec/fixtures/vcr_cassettes/event_trigger_success.yml
|
196
|
+
- spec/fixtures/vcr_cassettes/request_4001.yml
|
197
|
+
- spec/spec_helper.rb
|
198
|
+
has_rdoc:
|