acception-client 1.0.0
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 +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +3 -0
- data/README.md +71 -0
- data/Rakefile +2 -0
- data/acception-client.gemspec +28 -0
- data/config/locales/en.yml +10 -0
- data/lib/acception-client.rb +1 -0
- data/lib/acception/client.rb +29 -0
- data/lib/acception/client/configuration.rb +86 -0
- data/lib/acception/client/data.rb +9 -0
- data/lib/acception/client/data/create.rb +48 -0
- data/lib/acception/client/endpoint.rb +165 -0
- data/lib/acception/client/errors.rb +9 -0
- data/lib/acception/client/errors/create.rb +49 -0
- data/lib/acception/client/messages.rb +9 -0
- data/lib/acception/client/messages/create.rb +38 -0
- data/lib/acception/client/open_messages.rb +9 -0
- data/lib/acception/client/open_messages/create.rb +31 -0
- data/lib/acception/client/version.rb +7 -0
- data/lib/acception/message_type.rb +27 -0
- metadata +151 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 20ff2a379e7aefe8472423b60545e66a8554e360
|
|
4
|
+
data.tar.gz: 3732fd59dd29e75bec0a495fcc173fdc10082641
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dfc67c7ce940ab2f93e03fbfc24eade5d3a40e30226c4e76ebcd146d3667bd4778a85252b8cd4895ee95e3519244718fef3423280752f6419c55a967df217b6e
|
|
7
|
+
data.tar.gz: 433f78c5870fad8b18b749da88e59aacb3a6965134576901b444813e88fa384142d706fff75e9464032edd178b1c64700f8b44c42df6b762acc3fff013b7599b
|
data/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
acception-client
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.1.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# AcceptionClient
|
|
2
|
+
|
|
3
|
+
An API facade for the acception service.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
gem 'acception_client'
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install acception_client
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
All of the API facades use the /messages endpoint. The messages endpoint is very adaptable due to its architecture and the API facade
|
|
23
|
+
tries to abstract some of the complexities away with specific use cases that are useful. The most adaptable facade class is the
|
|
24
|
+
OpenMessage. The OpenMessage is the closest abstraction to the server side design. As such, it accepts any of the aspects that are
|
|
25
|
+
available in Acception.
|
|
26
|
+
|
|
27
|
+
The application parameter is only required if not proivded in the configuraiton (we strongly suggest to include this in the configuration).
|
|
28
|
+
If you do not include occurred_at in a data, message or open message, the current time is used.
|
|
29
|
+
|
|
30
|
+
### Data
|
|
31
|
+
|
|
32
|
+
data = "some-data-to-send-to-server"
|
|
33
|
+
client = Acception::Client::Data::Create.new( data, application: 'ncite',
|
|
34
|
+
name: "token",
|
|
35
|
+
content_type: "text/plain" )
|
|
36
|
+
# defaults to MessageType::DATA
|
|
37
|
+
client.call
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Error
|
|
41
|
+
|
|
42
|
+
client = Acception::Client::Errors::Create.new( error, application: 'ncite', # the application can be excluded if provided in the configuraiton
|
|
43
|
+
occurred_at: Time.now.utc )
|
|
44
|
+
# defaults to MessageType::ERROR
|
|
45
|
+
client.call
|
|
46
|
+
|
|
47
|
+
In order to override the default message type for an error, just pass it as an option.
|
|
48
|
+
|
|
49
|
+
client = Acception::Client::Errors::Create.new( error, application: 'ncite',
|
|
50
|
+
message_type: Acception::MessageType::FATAL,
|
|
51
|
+
occurred_at: Time.now.utc )
|
|
52
|
+
client.call
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Message
|
|
56
|
+
|
|
57
|
+
client = Acception::Client::Messages::Create.new( application: 'ncite',
|
|
58
|
+
occurred_at: Time.now.utc,
|
|
59
|
+
message: 'An message' )
|
|
60
|
+
# defaults to MessageType::INFO
|
|
61
|
+
client.call
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Open Message
|
|
65
|
+
|
|
66
|
+
client = Acception::Client::OpenMessages::Create.new( message_type: Acception::MessageType::EMERGENCY,
|
|
67
|
+
application: 'ncite',
|
|
68
|
+
occurred_at: Time.now.utc,
|
|
69
|
+
message: 'An open message',
|
|
70
|
+
path: 'asdf/asdf/asdf' )
|
|
71
|
+
client.call
|
data/Rakefile
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 'acception/client/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.authors = ["C. Jason Harrelson"]
|
|
8
|
+
spec.email = ["cjharrelson@iberon.com"]
|
|
9
|
+
spec.summary = %q{An API facade for the acception service.}
|
|
10
|
+
spec.description = %q{An API facade for the acception service. See README for more info.}
|
|
11
|
+
spec.homepage = "https://gitlab.staging.iberon.com/common/acception_client"
|
|
12
|
+
spec.license = ""
|
|
13
|
+
spec.name = "acception-client"
|
|
14
|
+
spec.version = Acception::Client::VERSION
|
|
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.6"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
|
|
24
|
+
spec.add_dependency "endow", "~> 1"
|
|
25
|
+
spec.add_dependency "enumerative"
|
|
26
|
+
spec.add_dependency "hashie"
|
|
27
|
+
spec.add_dependency "oj"
|
|
28
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'acception/client'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'endow'
|
|
2
|
+
require 'enumerative'
|
|
3
|
+
require 'hashie'
|
|
4
|
+
require 'time'
|
|
5
|
+
require 'acception/message_type'
|
|
6
|
+
require 'acception/client/version'
|
|
7
|
+
|
|
8
|
+
module Acception
|
|
9
|
+
module Client
|
|
10
|
+
|
|
11
|
+
autoload :Configuration, 'acception/client/configuration'
|
|
12
|
+
autoload :Data, 'acception/client/data'
|
|
13
|
+
autoload :Endpoint, 'acception/client/endpoint'
|
|
14
|
+
autoload :Errors, 'acception/client/errors'
|
|
15
|
+
autoload :Messages, 'acception/client/messages'
|
|
16
|
+
autoload :OpenMessages, 'acception/client/open_messages'
|
|
17
|
+
|
|
18
|
+
def self.configuration
|
|
19
|
+
@configuration ||= Configuration.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.configure
|
|
23
|
+
yield( configuration ) if block_given?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
I18n.load_path += Dir[File.expand_path( '../../../config/locales', __FILE__ ) + '/*.{rb,yml}']
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'endow'
|
|
2
|
+
|
|
3
|
+
module Acception
|
|
4
|
+
module Client
|
|
5
|
+
class Configuration
|
|
6
|
+
|
|
7
|
+
attr_accessor :application
|
|
8
|
+
|
|
9
|
+
def authentication_token
|
|
10
|
+
raise 'authentication_token configuration missing' unless @authentication_token
|
|
11
|
+
@authentication_token
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def authentication_token=( authentication_token )
|
|
15
|
+
@authentication_token = authentication_token
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def base_url
|
|
19
|
+
raise 'base_url configuration missing' unless @base_url
|
|
20
|
+
@base_url
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def base_url=( base_url )
|
|
24
|
+
@base_url = base_url
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def graceful_errors_map
|
|
28
|
+
@graceful_errors_map ||= {}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def graceful_errors_map=( map )
|
|
32
|
+
@graceful_errors_map = map
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def logger
|
|
36
|
+
@logger
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def logger=( logger )
|
|
40
|
+
@logger = logger
|
|
41
|
+
Endow.configure { |c| c.logger = logger }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def open_timeout_in_seconds
|
|
45
|
+
@open_timeout_in_seconds ||= 10
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def open_timeout_in_seconds=( open_timeout_in_seconds )
|
|
49
|
+
@open_timeout_in_seconds = open_timeout_in_seconds
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def read_timeout_in_seconds
|
|
53
|
+
@read_timeout_in_seconds ||= 10
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def read_timeout_in_seconds=( read_timeout_in_seconds )
|
|
57
|
+
@read_timeout_in_seconds = read_timeout_in_seconds
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def retry_sleep
|
|
61
|
+
@retry_sleep ||= false
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def retry_sleep=( retry_sleep )
|
|
65
|
+
@retry_sleep = retry_sleep
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def retry_attempts
|
|
69
|
+
@retry_attempts ||= 0
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def retry_attempts=( retry_attempts )
|
|
73
|
+
@retry_attempts = retry_attempts
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def ssl_verify_mode
|
|
77
|
+
@ssl_verify_mode ||= :none # one of [:none, :peer, :fail_if_no_peer_cert, :client_once]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def ssl_verify_mode=( ssl_verify_mode )
|
|
81
|
+
@ssl_verify_mode = ssl_verify_mode
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Acception
|
|
2
|
+
module Client
|
|
3
|
+
module Data
|
|
4
|
+
class Create < Acception::Client::Endpoint
|
|
5
|
+
|
|
6
|
+
def initialize( data, attributes={} )
|
|
7
|
+
@data = data
|
|
8
|
+
@attributes = attributes
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
|
|
13
|
+
attr_reader :data
|
|
14
|
+
|
|
15
|
+
def message_type
|
|
16
|
+
Acception::MessageType::DATA.key
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def occurred_at
|
|
20
|
+
(attributes[:occurred_at] || Time.now.utc).iso8601
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def variables
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
name: attributes[:name],
|
|
27
|
+
content: data,
|
|
28
|
+
content_type: attributes[:content_type]
|
|
29
|
+
}.reject { |k,v| v.blank? }
|
|
30
|
+
]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def endpoint
|
|
34
|
+
'/messages'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def http_verb
|
|
38
|
+
:post
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def success_error_codes
|
|
42
|
+
[201]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
module Acception
|
|
2
|
+
module Client
|
|
3
|
+
class Endpoint
|
|
4
|
+
|
|
5
|
+
include Endow::Endpoint
|
|
6
|
+
|
|
7
|
+
def call
|
|
8
|
+
set_content( synthesized_attributes )
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
attr_reader :attributes
|
|
15
|
+
|
|
16
|
+
def synthesized_attributes
|
|
17
|
+
{
|
|
18
|
+
application: application,
|
|
19
|
+
comment: comment,
|
|
20
|
+
environment: environment,
|
|
21
|
+
message: message,
|
|
22
|
+
message_type: message_type,
|
|
23
|
+
occurred_at: occurred_at,
|
|
24
|
+
path: path,
|
|
25
|
+
request_headers: request_headers,
|
|
26
|
+
request_parameters: request_parameters,
|
|
27
|
+
stack: stack,
|
|
28
|
+
session: session,
|
|
29
|
+
type: type,
|
|
30
|
+
variables: variables
|
|
31
|
+
}.reject { |k,v| v.blank? }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def application
|
|
35
|
+
application = attributes[:application] || Acception::Client::Configuration.application
|
|
36
|
+
raise 'application must be provided or configured for acception error reporting' unless application
|
|
37
|
+
application
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def comment
|
|
41
|
+
attributes[:comment]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def clean_text_for_request( text )
|
|
45
|
+
text.gsub( /\n\ \ /, "\n" ).
|
|
46
|
+
gsub( "`", "'" ).
|
|
47
|
+
gsub( "'", "\"" )
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def environment
|
|
51
|
+
attributes[:environment]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def message
|
|
55
|
+
attributes[:message]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def message_type
|
|
59
|
+
message_type = attributes[:message_type]
|
|
60
|
+
raise 'message_type is a required attribute' unless message_type
|
|
61
|
+
Acception::MessageType.new( message_type ).key
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def occurred_at
|
|
65
|
+
attributes[:occurred_at].try( :iso8601 )
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def path
|
|
69
|
+
attributes[:path]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def request_headers
|
|
73
|
+
attributes[:request_headers]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def request_parameters
|
|
77
|
+
attributes[:request_parameters]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def session
|
|
81
|
+
attributes[:session]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def stack
|
|
85
|
+
stack = attributes[:stack]
|
|
86
|
+
return nil unless stack
|
|
87
|
+
raise 'stack must be an Array' unless stack.is_a?( Array )
|
|
88
|
+
|
|
89
|
+
clean_text_for_request( stack.join( "\n" ))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def type
|
|
93
|
+
attributes[:type]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def variables
|
|
97
|
+
attributes[:variables]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def retryable_times
|
|
101
|
+
Acception::Client.configuration.retry_attempts
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def retryable_sleep
|
|
105
|
+
Acception::Client.configuration.retry_sleep
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def open_timeout_in_seconds
|
|
109
|
+
Acception::Client.configuration.open_timeout_in_seconds
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def read_timeout_in_seconds
|
|
113
|
+
Acception::Client.configuration.read_timeout_in_seconds
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def default_headers
|
|
117
|
+
{
|
|
118
|
+
'Accept' => accept,
|
|
119
|
+
'Content-Type' => content_type,
|
|
120
|
+
authentication_token_key => authentication_token
|
|
121
|
+
}.reject { |k,v| v.blank? }
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def accept
|
|
125
|
+
'application/vnd.acception-v1+json'
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def determine_accept_name
|
|
129
|
+
matches = accept.match( /(.*)\/vnd\.(.*)-(v\d+)\+(.*)/ )
|
|
130
|
+
[matches[1],
|
|
131
|
+
matches[4]].join( '_' )
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def content_type
|
|
135
|
+
'application/json'
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def response_wrapper_class
|
|
139
|
+
Hashie::Mash
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def authentication_token_key
|
|
143
|
+
'Auth-Token'
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def authentication_token
|
|
147
|
+
Acception::Client.configuration.authentication_token
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def base_url
|
|
151
|
+
File.join( Acception::Client.configuration.base_url ,
|
|
152
|
+
'api' )
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def ssl_verify_mode
|
|
156
|
+
Acception::Client.configuration.ssl_verify_mode
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def graceful_errors_map
|
|
160
|
+
Acception::Client.configuration.graceful_errors_map
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Acception
|
|
2
|
+
module Client
|
|
3
|
+
module Errors
|
|
4
|
+
class Create < Acception::Client::Endpoint
|
|
5
|
+
|
|
6
|
+
def initialize( error, attributes={} )
|
|
7
|
+
@error = error
|
|
8
|
+
@attributes = attributes
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
|
|
13
|
+
attr_reader :error
|
|
14
|
+
|
|
15
|
+
def message
|
|
16
|
+
error.try :message
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def message_type
|
|
20
|
+
Acception::MessageType.new( attributes[:message_type] || Acception::MessageType::ERROR ).key
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def stack
|
|
24
|
+
stack = error.try( :backtrace )
|
|
25
|
+
return nil unless stack
|
|
26
|
+
|
|
27
|
+
clean_text_for_request( stack.join( "\n" ))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def type
|
|
31
|
+
error.try( :class ).try( :name )
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def endpoint
|
|
35
|
+
'/messages'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def http_verb
|
|
39
|
+
:post
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def success_error_codes
|
|
43
|
+
[201]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Acception
|
|
2
|
+
module Client
|
|
3
|
+
module Messages
|
|
4
|
+
class Create < Acception::Client::Endpoint
|
|
5
|
+
|
|
6
|
+
def initialize( message, attributes={} )
|
|
7
|
+
@message = message
|
|
8
|
+
@attributes = attributes
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
|
|
13
|
+
attr_reader :message
|
|
14
|
+
|
|
15
|
+
def message_type
|
|
16
|
+
Acception::MessageType.new( attributes[:message_type] || Acception::MessageType::INFO ).key
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def occurred_at
|
|
20
|
+
(attributes[:occurred_at] || Time.now.utc).iso8601
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def endpoint
|
|
24
|
+
'/messages'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def http_verb
|
|
28
|
+
:post
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def success_error_codes
|
|
32
|
+
[201]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Acception
|
|
2
|
+
module Client
|
|
3
|
+
module OpenMessages
|
|
4
|
+
class Create < Acception::Client::Endpoint
|
|
5
|
+
|
|
6
|
+
def initialize( attributes )
|
|
7
|
+
@attributes = attributes
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
protected
|
|
11
|
+
|
|
12
|
+
def occurred_at
|
|
13
|
+
(attributes[:occurred_at] || Time.now.utc).iso8601
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def endpoint
|
|
17
|
+
'/messages'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def http_verb
|
|
21
|
+
:post
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def success_error_codes
|
|
25
|
+
[201]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Acception
|
|
2
|
+
class MessageType
|
|
3
|
+
|
|
4
|
+
def self.valid_keys
|
|
5
|
+
%w(
|
|
6
|
+
data
|
|
7
|
+
debug
|
|
8
|
+
emergency
|
|
9
|
+
error
|
|
10
|
+
fatal
|
|
11
|
+
info
|
|
12
|
+
warning
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
include Enumerative::Enumeration
|
|
17
|
+
|
|
18
|
+
# DATA
|
|
19
|
+
# DEBUG
|
|
20
|
+
# EMERGENCY
|
|
21
|
+
# ERROR
|
|
22
|
+
# FATAL
|
|
23
|
+
# INFO
|
|
24
|
+
# WARNING
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: acception-client
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- C. Jason Harrelson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-06-22 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.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: endow
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: enumerative
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
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: hashie
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
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: oj
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: An API facade for the acception service. See README for more info.
|
|
98
|
+
email:
|
|
99
|
+
- cjharrelson@iberon.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".ruby-gemset"
|
|
106
|
+
- ".ruby-version"
|
|
107
|
+
- Gemfile
|
|
108
|
+
- LICENSE.txt
|
|
109
|
+
- README.md
|
|
110
|
+
- Rakefile
|
|
111
|
+
- acception-client.gemspec
|
|
112
|
+
- config/locales/en.yml
|
|
113
|
+
- lib/acception-client.rb
|
|
114
|
+
- lib/acception/client.rb
|
|
115
|
+
- lib/acception/client/configuration.rb
|
|
116
|
+
- lib/acception/client/data.rb
|
|
117
|
+
- lib/acception/client/data/create.rb
|
|
118
|
+
- lib/acception/client/endpoint.rb
|
|
119
|
+
- lib/acception/client/errors.rb
|
|
120
|
+
- lib/acception/client/errors/create.rb
|
|
121
|
+
- lib/acception/client/messages.rb
|
|
122
|
+
- lib/acception/client/messages/create.rb
|
|
123
|
+
- lib/acception/client/open_messages.rb
|
|
124
|
+
- lib/acception/client/open_messages/create.rb
|
|
125
|
+
- lib/acception/client/version.rb
|
|
126
|
+
- lib/acception/message_type.rb
|
|
127
|
+
homepage: https://gitlab.staging.iberon.com/common/acception_client
|
|
128
|
+
licenses:
|
|
129
|
+
- ''
|
|
130
|
+
metadata: {}
|
|
131
|
+
post_install_message:
|
|
132
|
+
rdoc_options: []
|
|
133
|
+
require_paths:
|
|
134
|
+
- lib
|
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
145
|
+
requirements: []
|
|
146
|
+
rubyforge_project:
|
|
147
|
+
rubygems_version: 2.2.1
|
|
148
|
+
signing_key:
|
|
149
|
+
specification_version: 4
|
|
150
|
+
summary: An API facade for the acception service.
|
|
151
|
+
test_files: []
|