arkaan 2.8.0 → 3.2.2
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 +4 -4
- data/lib/arkaan.rb +18 -16
- data/lib/arkaan/account.rb +24 -19
- data/lib/arkaan/authentication.rb +4 -1
- data/lib/arkaan/authentication/device.rb +23 -0
- data/lib/arkaan/authentication/session.rb +28 -9
- 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 +3 -8
- 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,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module OAuth
|
3
5
|
# An access token is the value assigned to the application
|
@@ -9,18 +11,18 @@ module Arkaan
|
|
9
11
|
|
10
12
|
# @!attribute [rw] value
|
11
13
|
# @return [String] the value of the token, returned to the application when built.
|
12
|
-
field :value, type: String, default: ->{ SecureRandom.hex }
|
14
|
+
field :value, type: String, default: -> { SecureRandom.hex }
|
13
15
|
# @!attribute [rw] expiration
|
14
|
-
# @return [Integer] the time, in seconds, after which the token is declared expired, and thus can't be used
|
15
|
-
field :expiration, type: Integer, default:
|
16
|
+
# @return [Integer] the time, in seconds, after which the token is declared expired, and thus can't be used.
|
17
|
+
field :expiration, type: Integer, default: 86_400
|
16
18
|
|
17
19
|
# @!attribute [rw] authorization
|
18
|
-
# @return [Arkaan::OAuth::Authorization] the authorization code that issued this token to the application
|
20
|
+
# @return [Arkaan::OAuth::Authorization] the authorization code that issued this token to the application.
|
19
21
|
belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :tokens
|
20
22
|
|
21
|
-
validates :value,
|
22
|
-
|
23
|
-
|
23
|
+
validates :value,
|
24
|
+
presence: { message: 'required' },
|
25
|
+
uniqueness: { message: 'uniq' }
|
24
26
|
|
25
27
|
# Checks if the current date is inferior to the creation date + expiration period
|
26
28
|
# @return [Boolean] TRUE if the token is expired, FALSE otherwise.
|
@@ -29,4 +31,4 @@ module Arkaan
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
32
|
-
end
|
34
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module OAuth
|
3
|
-
# An application is what is referred to in the OAuth2.0 RFC as a client,
|
5
|
+
# An application is what is referred to in the OAuth2.0 RFC as a client,
|
6
|
+
# wanting to access private informations about the user.
|
4
7
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
8
|
class Application
|
6
9
|
include Mongoid::Document
|
@@ -11,9 +14,10 @@ module Arkaan
|
|
11
14
|
field :name, type: String
|
12
15
|
# @!attribute [rw] key
|
13
16
|
# @return [String] the unique key for the application, identifying it when requesting a token for the API.
|
14
|
-
field :
|
17
|
+
field :app_key, type: String, default: -> { SecureRandom.hex }
|
15
18
|
# @!attribute [rw] premium
|
16
|
-
# @return [Boolean] a value indicating whether the application should automatically receive a token
|
19
|
+
# @return [Boolean] a value indicating whether the application should automatically receive a token
|
20
|
+
# when an account is created, or not.
|
17
21
|
field :premium, type: Boolean, default: false
|
18
22
|
# @!attirbute [rw] redirect_uris
|
19
23
|
# @return [Array<String>] the redirection URIs used for this application.
|
@@ -23,17 +27,18 @@ module Arkaan
|
|
23
27
|
# @return [Arkaan::Account] the account that has created this application, considered its owner.
|
24
28
|
belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :applications
|
25
29
|
# @!attribute [rw] authorizations
|
26
|
-
# @return [Array<Arkaan::OAuth::Authorization>] the authorizations linked to the accounts
|
30
|
+
# @return [Array<Arkaan::OAuth::Authorization>] the authorizations linked to the accounts
|
31
|
+
# this application can get the data from.
|
27
32
|
has_many :authorizations, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :application
|
28
33
|
|
29
34
|
validates :name,
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
presence: { message: 'required' },
|
36
|
+
length: { minimum: 6, message: 'minlength' },
|
37
|
+
uniqueness: { message: 'uniq' }
|
33
38
|
|
34
|
-
validates :
|
35
|
-
|
36
|
-
|
39
|
+
validates :app_key,
|
40
|
+
presence: { message: 'required' },
|
41
|
+
uniqueness: { message: 'uniq' }
|
37
42
|
|
38
43
|
validate :redirect_uris_values
|
39
44
|
|
@@ -41,11 +46,12 @@ module Arkaan
|
|
41
46
|
# - it is a string
|
42
47
|
# - it has a correct URL format.
|
43
48
|
def redirect_uris_values
|
49
|
+
regex = %r{\A(https?:\/\/)((([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*)|(localhost:[0-9]{2,4})\/?)\z}
|
44
50
|
redirect_uris.each do |uri|
|
45
51
|
if !uri.is_a? String
|
46
52
|
errors.add(:redirect_uris, 'type')
|
47
53
|
break
|
48
|
-
elsif uri.match(
|
54
|
+
elsif uri.match(regex).nil?
|
49
55
|
errors.add(:redirect_uris, 'format')
|
50
56
|
break
|
51
57
|
end
|
@@ -53,4 +59,4 @@ module Arkaan
|
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
56
|
-
end
|
62
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module OAuth
|
3
5
|
# An OAuth authorization is granted by a user to an application to access its personal data.
|
@@ -10,8 +12,8 @@ module Arkaan
|
|
10
12
|
include Mongoid::Timestamps
|
11
13
|
|
12
14
|
# @!attribute [rw] code
|
13
|
-
# @return [String] the value corresponding to the authentication code in the RFC of OAuth2.0
|
14
|
-
field :code, type: String, default: ->{ SecureRandom.hex }
|
15
|
+
# @return [String] the value corresponding to the authentication code in the RFC of OAuth2.0.
|
16
|
+
field :code, type: String, default: -> { SecureRandom.hex }
|
15
17
|
|
16
18
|
# @!attribute [rw] account
|
17
19
|
# @return [Arkaaan::Account] the account granting the authorization to access its data to the application.
|
@@ -20,12 +22,12 @@ module Arkaan
|
|
20
22
|
# @return [Arkaan::OAuth::Application] the application asking to access account's data.
|
21
23
|
belongs_to :application, class_name: 'Arkaan::OAuth::Application', inverse_of: :authorizations
|
22
24
|
# @!attribute [rw] token
|
23
|
-
# @return [Arkaan::OAuth::AccessToken] the access token used further in the application process to access
|
25
|
+
# @return [Arkaan::OAuth::AccessToken] the access token used further in the application process to access data.
|
24
26
|
has_many :tokens, class_name: 'Arkaan::OAuth::AccessToken', inverse_of: :authorization
|
25
27
|
|
26
28
|
validates :code,
|
27
|
-
|
28
|
-
|
29
|
+
presence: { message: 'required' },
|
30
|
+
uniqueness: { message: 'uniq' }
|
29
31
|
end
|
30
32
|
end
|
31
|
-
end
|
33
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module OAuth
|
3
|
-
# A refresh token is used when an access token is expired, to get a new one.
|
5
|
+
# A refresh token is used when an access token is expired, to get a new one.
|
6
|
+
# It is then recreated for the next expiration.
|
4
7
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
8
|
class RefreshToken
|
6
9
|
include Mongoid::Document
|
@@ -8,11 +11,11 @@ module Arkaan
|
|
8
11
|
|
9
12
|
# @!attribute [rw] value
|
10
13
|
# @return [String] the value of the token, returned to the application when built.
|
11
|
-
field :value, type: String, default: ->{ SecureRandom.hex }
|
14
|
+
field :value, type: String, default: -> { SecureRandom.hex }
|
12
15
|
|
13
16
|
# @!attribute [rw] authorization
|
14
|
-
# @return [Arkaan::OAuth::Authorization] the authorization code that issued this token to the application
|
17
|
+
# @return [Arkaan::OAuth::Authorization] the authorization code that issued this token to the application.
|
15
18
|
belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :refresh_token
|
16
19
|
end
|
17
20
|
end
|
18
|
-
end
|
21
|
+
end
|
data/lib/arkaan/permissions.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
# This module holds the logic for all the classes concerning the permissions abd rights for the user.
|
3
5
|
# A permission is restricting the access to one or several features to the users having it.
|
4
6
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
7
|
module Permissions
|
6
|
-
autoload :Right
|
7
|
-
autoload :Group
|
8
|
+
autoload :Right, 'arkaan/permissions/right'
|
9
|
+
autoload :Group, 'arkaan/permissions/group'
|
8
10
|
autoload :Category, 'arkaan/permissions/category'
|
9
11
|
end
|
10
|
-
end
|
12
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module Permissions
|
3
5
|
# A category of rights regroups one or several rights for convenience purposes.
|
@@ -9,7 +11,7 @@ module Arkaan
|
|
9
11
|
|
10
12
|
has_many :rights, class_name: 'Arkaan::Permissions::Right', inverse_of: :category
|
11
13
|
|
12
|
-
make_sluggable
|
14
|
+
make_sluggable
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module Permissions
|
3
5
|
# A group gathers one or several users to give them the same rights for conviniency purposes.
|
@@ -24,7 +26,7 @@ module Arkaan
|
|
24
26
|
# @return [Array<Arkaan::Monitoring::Route>] the routes this group can access in the API.
|
25
27
|
has_and_belongs_to_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :groups
|
26
28
|
|
27
|
-
make_sluggable
|
29
|
+
make_sluggable
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module Permissions
|
3
|
-
# A right is the access to one or several features in the application.
|
5
|
+
# A right is the access to one or several features in the application.
|
6
|
+
# It's applied to a group, and transitively to an account.
|
4
7
|
# @author Vincent Courtois <courtois;vincent@outlook.com>
|
5
8
|
class Right
|
6
9
|
include Mongoid::Document
|
@@ -8,12 +11,13 @@ module Arkaan
|
|
8
11
|
include Arkaan::Concerns::Sluggable
|
9
12
|
|
10
13
|
# @!attribute [rw] groups
|
11
|
-
# @return [Array<Arkaan::Permissions::Group>] the groups granted with the permission to
|
14
|
+
# @return [Array<Arkaan::Permissions::Group>] the groups granted with the permission to
|
15
|
+
# access features opened by this right.
|
12
16
|
has_and_belongs_to_many :groups, class_name: 'Arkaan::Permissions::Group', inverse_of: :rights
|
13
17
|
|
14
18
|
belongs_to :category, class_name: 'Arkaan::Permissions::Category', inverse_of: :rights
|
15
19
|
|
16
|
-
make_sluggable
|
20
|
+
make_sluggable
|
17
21
|
end
|
18
22
|
end
|
19
|
-
end
|
23
|
+
end
|
data/lib/arkaan/ruleset.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
# A set of rules is describing how a specific game system works (eg. Dungeons and Dragons 5th Edition, or Fate)
|
3
5
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
@@ -23,8 +25,8 @@ module Arkaan
|
|
23
25
|
has_many :campaigns, class_name: 'Arkaan::Campaign', inverse_of: :ruleset
|
24
26
|
|
25
27
|
validates :name,
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
presence: { message: 'required' },
|
29
|
+
length: { minimum: 4, message: 'minlength', if: :name? },
|
30
|
+
uniqueness: { message: 'uniq', if: :name? }
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_cleaner
|
@@ -313,6 +313,7 @@ files:
|
|
313
313
|
- lib/arkaan.rb
|
314
314
|
- lib/arkaan/account.rb
|
315
315
|
- lib/arkaan/authentication.rb
|
316
|
+
- lib/arkaan/authentication/device.rb
|
316
317
|
- lib/arkaan/authentication/session.rb
|
317
318
|
- lib/arkaan/campaign.rb
|
318
319
|
- lib/arkaan/campaigns.rb
|
@@ -333,13 +334,8 @@ files:
|
|
333
334
|
- lib/arkaan/concerns/premiumable.rb
|
334
335
|
- lib/arkaan/concerns/sluggable.rb
|
335
336
|
- lib/arkaan/concerns/typable.rb
|
336
|
-
- lib/arkaan/decorators/errors.rb
|
337
|
-
- lib/arkaan/decorators/errors/env_variable_missing.rb
|
338
|
-
- lib/arkaan/decorators/gateway.rb
|
339
337
|
- lib/arkaan/event.rb
|
340
338
|
- lib/arkaan/factories.rb
|
341
|
-
- lib/arkaan/factories/errors.rb
|
342
|
-
- lib/arkaan/factories/errors/gateway_not_found.rb
|
343
339
|
- lib/arkaan/files.rb
|
344
340
|
- lib/arkaan/files/document.rb
|
345
341
|
- lib/arkaan/files/permission.rb
|
@@ -357,7 +353,6 @@ files:
|
|
357
353
|
- lib/arkaan/permissions/group.rb
|
358
354
|
- lib/arkaan/permissions/right.rb
|
359
355
|
- lib/arkaan/ruleset.rb
|
360
|
-
- lib/arkaan/version.rb
|
361
356
|
homepage: https://rubygems.org/gems/arkaan
|
362
357
|
licenses:
|
363
358
|
- MIT
|
@@ -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
|