arkaan 2.7.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan.rb +18 -16
- data/lib/arkaan/account.rb +22 -19
- data/lib/arkaan/authentication.rb +3 -1
- data/lib/arkaan/authentication/session.rb +10 -7
- data/lib/arkaan/campaign.rb +21 -19
- data/lib/arkaan/campaigns.rb +4 -2
- data/lib/arkaan/campaigns/invitation.rb +2 -2
- data/lib/arkaan/chatrooms.rb +7 -5
- data/lib/arkaan/chatrooms/base.rb +3 -1
- data/lib/arkaan/chatrooms/campaign.rb +3 -1
- data/lib/arkaan/chatrooms/conversation.rb +5 -1
- data/lib/arkaan/chatrooms/membership.rb +6 -2
- data/lib/arkaan/chatrooms/message.rb +5 -3
- data/lib/arkaan/concerns.rb +10 -8
- data/lib/arkaan/concerns/activable.rb +6 -4
- data/lib/arkaan/concerns/diagnosticable.rb +7 -5
- data/lib/arkaan/concerns/enumerable.rb +21 -9
- data/lib/arkaan/concerns/historizable.rb +7 -5
- data/lib/arkaan/concerns/mime_typable.rb +18 -10
- data/lib/arkaan/concerns/premiumable.rb +3 -1
- data/lib/arkaan/concerns/sluggable.rb +9 -8
- data/lib/arkaan/concerns/typable.rb +5 -3
- data/lib/arkaan/factories.rb +4 -2
- data/lib/arkaan/files.rb +6 -2
- data/lib/arkaan/files/document.rb +5 -3
- data/lib/arkaan/files/permission.rb +4 -2
- data/lib/arkaan/monitoring.rb +4 -2
- data/lib/arkaan/monitoring/route.rb +6 -3
- data/lib/arkaan/monitoring/service.rb +5 -3
- data/lib/arkaan/notification.rb +5 -2
- data/lib/arkaan/oauth.rb +6 -4
- data/lib/arkaan/oauth/access_token.rb +10 -8
- data/lib/arkaan/oauth/application.rb +18 -12
- data/lib/arkaan/oauth/authorization.rb +8 -6
- data/lib/arkaan/oauth/refresh_token.rb +7 -4
- data/lib/arkaan/permissions.rb +5 -3
- data/lib/arkaan/permissions/category.rb +4 -2
- data/lib/arkaan/permissions/group.rb +4 -2
- data/lib/arkaan/permissions/right.rb +8 -4
- data/lib/arkaan/ruleset.rb +6 -4
- metadata +104 -54
- data/lib/arkaan/decorators/errors.rb +0 -9
- data/lib/arkaan/decorators/errors/env_variable_missing.rb +0 -14
- data/lib/arkaan/decorators/gateway.rb +0 -109
- data/lib/arkaan/factories/errors.rb +0 -9
- data/lib/arkaan/factories/errors/gateway_not_found.rb +0 -14
- data/lib/arkaan/version.rb +0 -3
@@ -1,9 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Decorators
|
3
|
-
# Module holding all the errors concerning the code of the decorators.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
module Errors
|
6
|
-
autoload :EnvVariableMissing, 'arkaan/decorators/errors/env_variable_missing'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Decorators
|
3
|
-
module Errors
|
4
|
-
# Error raised if the application key variable is missing.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class EnvVariableMissing < Arkaan::Utils::Errors::HTTPError
|
7
|
-
|
8
|
-
def initialize(action:)
|
9
|
-
super(action, 'app_key', 'not_found', 404)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Decorators
|
3
|
-
# Decorator for a service, providing methods to make requests on it.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
class Gateway < Draper::Decorator
|
6
|
-
delegate_all
|
7
|
-
|
8
|
-
# @!attribute [rw] action
|
9
|
-
# @return [String] the action of the route using this API.
|
10
|
-
attr_accessor :action
|
11
|
-
|
12
|
-
attr_accessor :logger
|
13
|
-
|
14
|
-
def initialize(action, _object)
|
15
|
-
super(_object)
|
16
|
-
@logger = Logger.new(STDOUT)
|
17
|
-
@action = action
|
18
|
-
end
|
19
|
-
|
20
|
-
# Shortcut to make a DELETE request on the API.
|
21
|
-
# @param session [Arkaan::Authentication::Session] the session of the user requesting the API.
|
22
|
-
# @param url [String] the URL you want to reach on the service.
|
23
|
-
# @param params [Hash] the additional parameters to pass in the JSON body.
|
24
|
-
def delete(session:, url:, params:)
|
25
|
-
return make_request_without_body(verb: 'delete', session: session, url: url, params: params)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Shortcut to make a GET request on the API.
|
29
|
-
# @param session [Arkaan::Authentication::Session] the session of the user requesting the API.
|
30
|
-
# @param url [String] the URL you want to reach on the service.
|
31
|
-
# @param params [Hash] the additional parameters to pass in the JSON body.
|
32
|
-
def get(session:, url:, params:)
|
33
|
-
return make_request_without_body(verb: 'get', session: session, url: url, params: params)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Shortcut to make a POST request on the API.
|
37
|
-
# @param session [Arkaan::Authentication::Session] the session of the user requesting the API.
|
38
|
-
# @param url [String] the URL you want to reach on the service.
|
39
|
-
# @param params [Hash] the additional parameters to pass in the JSON body.
|
40
|
-
def post(session:, url:, params:)
|
41
|
-
return make_request(verb: 'post', session: session, url: url, params: params)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Shortcut to make a PUT request on the API.
|
45
|
-
# @param session [Arkaan::Authentication::Session] the session of the user requesting the API.
|
46
|
-
# @param url [String] the URL you want to reach on the service.
|
47
|
-
# @param params [Hash] the additional parameters to pass in the JSON body.
|
48
|
-
def put(session:, url:, params:)
|
49
|
-
return make_request(verb: 'put', session: session, url: url, params: params)
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
# Makes a POST request to the given service with the following steps :
|
55
|
-
# 1. Gets an active and running instance of the service to make the request.
|
56
|
-
# 2. Creates a Faraday connection to use it as a pipeline for the request.
|
57
|
-
# 3. Makes the actual request and returns an object with the status and body of the response.
|
58
|
-
#
|
59
|
-
# @param verb [String] the HTTP verb to use for this request.
|
60
|
-
# @param session [Arkaan::Authentication::Session] the session of the user requesting the API.
|
61
|
-
# @param url [String] the URL you want to reach on the service.
|
62
|
-
# @param params [Hash] the additional parameters to pass in the JSON body.
|
63
|
-
#
|
64
|
-
# @return [Hash, Boolean] FALSE if no instance are found, or an object with :status and :body keys correspding
|
65
|
-
# to the status and body of the response to the request
|
66
|
-
def make_request(verb:, session:, url:, params:)
|
67
|
-
params = before_requests(session, params)
|
68
|
-
connection = get_connection
|
69
|
-
|
70
|
-
response = connection.send(verb) do |req|
|
71
|
-
req.url url
|
72
|
-
req.headers['Content-Type'] = 'application/json'
|
73
|
-
req.body = params.to_json
|
74
|
-
end
|
75
|
-
|
76
|
-
return {
|
77
|
-
status: response.status,
|
78
|
-
body: JSON.parse(response.body)
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
def make_request_without_body(verb:, session:, url:, params:)
|
83
|
-
params = before_requests(session, params)
|
84
|
-
connection = get_connection
|
85
|
-
response = connection.send(verb) do |req|
|
86
|
-
req.url url, params
|
87
|
-
req.headers['Content-Type'] = 'application/json'
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def before_requests(session, params)
|
92
|
-
if ENV['APP_KEY'].nil?
|
93
|
-
raise Arkaan::Decorators::Errors::EnvVariableMissing.new(action: action)
|
94
|
-
end
|
95
|
-
params[:app_key] = ENV['APP_KEY']
|
96
|
-
params[:session_id] = session.token
|
97
|
-
return params
|
98
|
-
end
|
99
|
-
|
100
|
-
def get_connection
|
101
|
-
Faraday.new(object.url) do |faraday|
|
102
|
-
faraday.request :url_encoded
|
103
|
-
faraday.response :logger
|
104
|
-
faraday.adapter Faraday.default_adapter
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Factories
|
3
|
-
# Module holding all the errors concerning the code of the factories.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
module Errors
|
6
|
-
autoload :GatewayNotFound, 'arkaan/factories/errors/gateway_not_found'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Factories
|
3
|
-
module Errors
|
4
|
-
# Error raised when not gateway active and running is found in the factory.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class GatewayNotFound < Arkaan::Utils::Errors::HTTPError
|
7
|
-
|
8
|
-
def initialize(action:)
|
9
|
-
super(action, 'gateway_id', 'not_found', 404)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/arkaan/version.rb
DELETED