arkaan 2.7.1 → 3.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arkaan.rb +18 -16
  3. data/lib/arkaan/account.rb +22 -19
  4. data/lib/arkaan/authentication.rb +3 -1
  5. data/lib/arkaan/authentication/session.rb +10 -7
  6. data/lib/arkaan/campaign.rb +21 -19
  7. data/lib/arkaan/campaigns.rb +4 -2
  8. data/lib/arkaan/campaigns/invitation.rb +2 -2
  9. data/lib/arkaan/chatrooms.rb +7 -5
  10. data/lib/arkaan/chatrooms/base.rb +3 -1
  11. data/lib/arkaan/chatrooms/campaign.rb +3 -1
  12. data/lib/arkaan/chatrooms/conversation.rb +5 -1
  13. data/lib/arkaan/chatrooms/membership.rb +6 -2
  14. data/lib/arkaan/chatrooms/message.rb +5 -3
  15. data/lib/arkaan/concerns.rb +10 -8
  16. data/lib/arkaan/concerns/activable.rb +6 -4
  17. data/lib/arkaan/concerns/diagnosticable.rb +7 -5
  18. data/lib/arkaan/concerns/enumerable.rb +21 -9
  19. data/lib/arkaan/concerns/historizable.rb +7 -5
  20. data/lib/arkaan/concerns/mime_typable.rb +18 -10
  21. data/lib/arkaan/concerns/premiumable.rb +3 -1
  22. data/lib/arkaan/concerns/sluggable.rb +9 -8
  23. data/lib/arkaan/concerns/typable.rb +5 -3
  24. data/lib/arkaan/factories.rb +4 -2
  25. data/lib/arkaan/files.rb +6 -2
  26. data/lib/arkaan/files/document.rb +5 -3
  27. data/lib/arkaan/files/permission.rb +4 -2
  28. data/lib/arkaan/monitoring.rb +4 -2
  29. data/lib/arkaan/monitoring/route.rb +6 -3
  30. data/lib/arkaan/monitoring/service.rb +5 -3
  31. data/lib/arkaan/notification.rb +5 -2
  32. data/lib/arkaan/oauth.rb +6 -4
  33. data/lib/arkaan/oauth/access_token.rb +10 -8
  34. data/lib/arkaan/oauth/application.rb +18 -12
  35. data/lib/arkaan/oauth/authorization.rb +8 -6
  36. data/lib/arkaan/oauth/refresh_token.rb +7 -4
  37. data/lib/arkaan/permissions.rb +5 -3
  38. data/lib/arkaan/permissions/category.rb +4 -2
  39. data/lib/arkaan/permissions/group.rb +4 -2
  40. data/lib/arkaan/permissions/right.rb +8 -4
  41. data/lib/arkaan/ruleset.rb +6 -4
  42. metadata +104 -54
  43. data/lib/arkaan/decorators/errors.rb +0 -9
  44. data/lib/arkaan/decorators/errors/env_variable_missing.rb +0 -14
  45. data/lib/arkaan/decorators/gateway.rb +0 -109
  46. data/lib/arkaan/factories/errors.rb +0 -9
  47. data/lib/arkaan/factories/errors/gateway_not_found.rb +0 -14
  48. 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
@@ -1,3 +0,0 @@
1
- module Arkaan
2
- VERSION = '2.7.1'
3
- end