kaze_client 0.1.1p0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +18 -0
  3. data/.gitignore +16 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +2 -0
  6. data/CHANGELOG.md +16 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +64 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +37 -0
  12. data/Rakefile +12 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/kaze_client.gemspec +36 -0
  16. data/lib/activesupport/blank.rb +155 -0
  17. data/lib/activesupport/camelize.rb +32 -0
  18. data/lib/kaze_client/client.rb +99 -0
  19. data/lib/kaze_client/error/disabled_account.rb +13 -0
  20. data/lib/kaze_client/error/forbidden.rb +13 -0
  21. data/lib/kaze_client/error/generic.rb +29 -0
  22. data/lib/kaze_client/error/internal_server_error.rb +13 -0
  23. data/lib/kaze_client/error/invalid_credentials.rb +13 -0
  24. data/lib/kaze_client/error/no_endpoint.rb +19 -0
  25. data/lib/kaze_client/error/no_private_token.rb +13 -0
  26. data/lib/kaze_client/error/not_found.rb +13 -0
  27. data/lib/kaze_client/error/unauthorized.rb +13 -0
  28. data/lib/kaze_client/errors.rb +12 -0
  29. data/lib/kaze_client/request/request.rb +113 -0
  30. data/lib/kaze_client/request/requests/assign_performer_request.rb +23 -0
  31. data/lib/kaze_client/request/requests/create_job_request.rb +32 -0
  32. data/lib/kaze_client/request/requests/job_request.rb +17 -0
  33. data/lib/kaze_client/request/requests/job_workflow_request.rb +25 -0
  34. data/lib/kaze_client/request/requests/job_workflows_request.rb +19 -0
  35. data/lib/kaze_client/request/requests/jobs_request.rb +18 -0
  36. data/lib/kaze_client/request/requests/login_request.rb +28 -0
  37. data/lib/kaze_client/request/requests/partners_request.rb +19 -0
  38. data/lib/kaze_client/request/requests/profile_request.rb +17 -0
  39. data/lib/kaze_client/request/requests/update_template_request.rb +19 -0
  40. data/lib/kaze_client/request/requests/utils/authentified_request.rb +25 -0
  41. data/lib/kaze_client/request/requests/utils/final_request.rb +13 -0
  42. data/lib/kaze_client/request/requests/utils/list_request.rb +120 -0
  43. data/lib/kaze_client/requests.rb +23 -0
  44. data/lib/kaze_client/response.rb +34 -0
  45. data/lib/kaze_client/version.rb +5 -0
  46. data/lib/kaze_client.rb +17 -0
  47. metadata +114 -0
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # Generic 403 error sent by Kaze server
7
+ class Forbidden < Generic
8
+ def initialize(msg = '403 Forbidden')
9
+ super(status: :forbidden, message: msg)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @since 0.1.0
5
+ module Error
6
+ # @author ciappa_m@modulotech.fr
7
+ # Generic error raised when Kaze server send an unknown error. By default, it is considered
8
+ # to be an internal server error.
9
+ class Generic < RuntimeError
10
+ # @return [Symbol] The HTTP status sent by the server
11
+ attr_reader :status
12
+
13
+ # @return [String] if the server sent a custom error code
14
+ # @return [Symbol] if the server sent no code, it is the HTTP status sent by the server
15
+ attr_reader :error
16
+
17
+ # The default error message
18
+ DEFAULT_MESSAGE = 'An unknown error occured'
19
+
20
+ def initialize(status: :internal_server_error, error: nil,
21
+ message: DEFAULT_MESSAGE)
22
+ super(message || DEFAULT_MESSAGE)
23
+
24
+ @status = status || :internal_server_error
25
+ @error = error || @status
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # Generic 500 error sent by Kaze server
7
+ class InternalServerError < Generic
8
+ def initialize(msg = 'An unknown error occured')
9
+ super(message: msg)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # 401 error sent by Kaze server when trying to log in with invalid credentials
7
+ class InvalidCredentials < Unauthorized
8
+ def initialize(msg = 'Invalid Login or Password')
9
+ super(msg)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # An error raised when the base URL given to the +KazeClient::Client+ is nil
7
+ # @see KazeClient::Client
8
+ class NoEndpoint < Generic
9
+ # @return the given base URL
10
+ attr_reader :base_url
11
+
12
+ def initialize(base_url)
13
+ super(status: nil, message: "Invalid base url +#{base_url}+", error: nil)
14
+
15
+ @base_url = base_url
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # 403 error sent by Kaze server when trying to log in and user has no token
7
+ class NoPrivateToken < Forbidden
8
+ def initialize(msg = 'User has no private token assigned')
9
+ super(msg)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # 404 error sent by Kaze server
7
+ class NotFound < Generic
8
+ def initialize(msg = '404 Not Found')
9
+ super(status: :not_found, message: msg)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Error
5
+ # @author ciappa_m@modulotech.fr
6
+ # Generic 401 error sent by Kaze server
7
+ class Unauthorized < Generic
8
+ def initialize(msg = '401 Unauthorized')
9
+ super(status: :unauthorized, message: msg)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Require the error classes
4
+ require_relative 'error/generic'
5
+ require_relative 'error/unauthorized'
6
+ require_relative 'error/forbidden'
7
+ require_relative 'error/not_found'
8
+ require_relative 'error/internal_server_error'
9
+ require_relative 'error/disabled_account'
10
+ require_relative 'error/invalid_credentials'
11
+ require_relative 'error/no_endpoint'
12
+ require_relative 'error/no_private_token'
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Represents request to a Kaze API
6
+ # @see KazeClient::Client
7
+ # @see KazeClient::Response
8
+ # @since 0.1.0
9
+ class Request
10
+ # Those headers are added on all requests by default
11
+ DEFAULT_HEADERS = {
12
+ 'Content-Type' => 'application/json',
13
+ 'Accept' => 'application/json'
14
+ }.freeze
15
+
16
+ # @return [String, Symbol] The HTTP verb to use for the request
17
+ # @example Common HTTP verbs
18
+ # [:get, :post, :put, :patch, :delete]
19
+ attr_reader :method
20
+
21
+ # @return [String] The API endpoint
22
+ # @example To get the list of companies
23
+ # '/api/companies'
24
+ attr_reader :url
25
+
26
+ # @return [nil, Hash] The query parameters for the request
27
+ # @example Page parameters from KazeClient::Utils::ListRequest
28
+ # { page: 1, per_page: 20 }
29
+ attr_accessor :query
30
+
31
+ # @return [nil, Hash, String] The body for the request
32
+ # @example Login data from KazeClient::LoginRequest
33
+ # { user: { login: 'test', password: 'test' } }
34
+ # "{\"user\":{\"login\":\"test\",\"password\":\"test\"}}"
35
+ attr_accessor :body
36
+
37
+ # @return [nil, Hash] The headers for the request
38
+ # @example Default headers from any KazeClient::Request
39
+ # { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
40
+ attr_accessor :headers
41
+
42
+ # @param method [Symbol] The HTTP verb to use for the request (e.g. :get)
43
+ # @param url [String] The API endpoint (e.g. /jobs)
44
+ def initialize(method, url)
45
+ @method = method
46
+ @url = url
47
+ @query = nil
48
+ @body = nil
49
+ @headers = {}
50
+ end
51
+
52
+ # @return [Hash] The arguments to give to the HTTParty call
53
+ # @example For instance, when +@body+ is blank
54
+ # {
55
+ # query: { page: 1, per_page: 20 },
56
+ # headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
57
+ # }
58
+ def parameters
59
+ {
60
+ query: make_query, body: make_body, headers: make_headers
61
+ }.reject { |_k, v| v.blank? }
62
+ end
63
+
64
+ # @param response [HTTParty::Response] The response object from HTTParty call
65
+ # @return [KazeClient::Error::Generic] The adequate error object according to the given response
66
+ def error_for(response)
67
+ # Not found is handled in a specific way since there is no message key and the error has a
68
+ # specific format
69
+ return KazeClient::Error::NotFound.new if response.code == 404
70
+
71
+ # Return the adequate error class for the error code in the response
72
+ "KazeClient::Error::#{response.parsed_response['error'].camelize}"
73
+ .constantize.new(response.parsed_response['message'])
74
+ rescue NameError
75
+ # This means no error class exists for the error code in the response, we fallback to a
76
+ # generic error
77
+ Error::Generic.new(status: response.code,
78
+ error: response.parsed_response['error'],
79
+ message: response.parsed_response['message'])
80
+ end
81
+
82
+ protected
83
+
84
+ # @return [Hash] The headers for the request
85
+ # If +@headers+ is blank or is not a Hash, it returns the +DEFAULT_HEADERS+. Else it merges
86
+ # the +DEFAULT_HEADERS+ with +@headers+ allowing +@headers+ to override +DEFAULT_HEADERS+.
87
+ def make_headers
88
+ return DEFAULT_HEADERS if @headers.blank? || !@headers.is_a?(Hash)
89
+
90
+ DEFAULT_HEADERS.merge(@headers)
91
+ end
92
+
93
+ # @return [nil, String] The body for the request
94
+ # +String+ will be sent as-is while +Hash+ will be transformed to a JSON string.
95
+ def make_body
96
+ return nil if @body.blank?
97
+
98
+ case @body
99
+ when String
100
+ @body
101
+ when Hash
102
+ @body.to_json
103
+ end
104
+ end
105
+
106
+ # @return [nil, Hash] The query parameters for the request
107
+ def make_query
108
+ return nil if @query.blank?
109
+
110
+ @query
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Assign a performer to the given job.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class AssignPerformerRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+
13
+ def initialize(id, performer_user_id)
14
+ super(:post, "api/jobs/#{id}/performers")
15
+
16
+ @body = {
17
+ job: {
18
+ performer_user_id: performer_user_id.to_s
19
+ }
20
+ }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Create a job from the current user to the target company.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class CreateJobRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+
13
+ # @return [String] The id of the target company.
14
+ attr_reader :target_id
15
+
16
+ # @return [Hash] The workflow used to create the job.
17
+ attr_reader :workflow
18
+
19
+ # @param target_id [String] The id of the target company.
20
+ # @param workflow [Hash] The workflow to use to create the job.
21
+ def initialize(target_id, workflow)
22
+ super(:post, 'api/jobs')
23
+
24
+ @target_id = target_id
25
+ @workflow = workflow
26
+ @body = {
27
+ target_id: @target_id,
28
+ workflow: @workflow
29
+ }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Fetch the details for the given job id.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class JobRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+
13
+ def initialize(id)
14
+ super(:get, "api/jobs/#{id}")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Request the details about a specific workflow.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class JobWorkflowRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+
13
+ # @return [String] The id of the workflow to request
14
+ attr_reader :id
15
+
16
+ # @param id [String] Set the id of the workflow to request
17
+ def initialize(id)
18
+ super(:get, "api/job_workflows/#{id}")
19
+
20
+ @id = id
21
+ @query = {}
22
+ @filters = {}
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Request the list of job workflows for the current user.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @see KazeClient::Utils::ListRequest
10
+ # @since 0.1.0
11
+ class JobWorkflowsRequest < Utils::FinalRequest
12
+ include Utils::AuthentifiedRequest
13
+ include Utils::ListRequest
14
+
15
+ def initialize
16
+ super(:get, 'api/job_workflows')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # List the jobs assigned to the current user's company.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class JobsRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+ include Utils::ListRequest
13
+
14
+ def initialize
15
+ super(:get, 'api/jobs')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Authenticate a user on the server.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @since 0.1.0
9
+ class LoginRequest < Utils::FinalRequest
10
+ # @return [String] The user login.
11
+ attr_reader :login
12
+
13
+ # @param login [String] The user login.
14
+ # @param password [String] The user password.
15
+ def initialize(login:, password:)
16
+ super(:post, 'api/login')
17
+
18
+ @login = login
19
+ @password = password
20
+ @body = {
21
+ user: {
22
+ login: @login,
23
+ password: @password
24
+ }
25
+ }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Request the list of companies.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @see KazeClient::Utils::ListRequest
10
+ # @since 0.1.0
11
+ class PartnersRequest < Utils::FinalRequest
12
+ include Utils::AuthentifiedRequest
13
+ include Utils::ListRequest
14
+
15
+ def initialize
16
+ super(:get, 'api/partners')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Request data about the current user.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class ProfileRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+
13
+ def initialize
14
+ super(:get, 'api/profile')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @author ciappa_m@modulotech.fr
5
+ # Update data of the given template on the given job.
6
+ # @see KazeClient::Request
7
+ # @see KazeClient::Utils::FinalRequest
8
+ # @see KazeClient::Utils::AuthentifiedRequest
9
+ # @since 0.1.0
10
+ class UpdateTemplateRequest < Utils::FinalRequest
11
+ include Utils::AuthentifiedRequest
12
+
13
+ def initialize(id, template_id, body)
14
+ super(:put, "api/performer/jobs/#{id}/templates/#{template_id}")
15
+
16
+ @body = body
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ # @since 0.1.0
5
+ module Utils
6
+ # @author ciappa_m@modulotech.fr
7
+ # Included by the request where an authentication token is required.
8
+ # @see KazeClient::Request
9
+ module AuthentifiedRequest
10
+ # @return [String] The authentication token
11
+ attr_reader :token
12
+
13
+ # Store the given authentication token and use it to set the +Authorization+ header of the
14
+ # request.
15
+ # @param token [String] The authentication token
16
+ # @return [KazeClient::Utils::AuthentifiedRequest] self (to chain methods)
17
+ def with_token(token)
18
+ @token = token
19
+ @headers['Authorization'] = token
20
+
21
+ self
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Utils
5
+ # @author ciappa_m@modulotech.fr
6
+ # Set the request as final, disabling the edition of query parameters, headers and request body.
7
+ # @see KazeClient::Request
8
+ class FinalRequest < Request
9
+ # Remove write access inherited from Request
10
+ undef_method :query=, :body=, :headers=
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KazeClient
4
+ module Utils
5
+ # @author ciappa_m@modulotech.fr
6
+ # Included by the request where a list will be returned.
7
+ # @see KazeClient::Request
8
+ module ListRequest
9
+ # @return [Integer,String] The page to fetch.
10
+ attr_reader :page
11
+
12
+ # @return [Integer] The number of items to fetch by page; between 1 and 100.
13
+ attr_reader :per_page
14
+
15
+ # @return [String] The field to use for the list order.
16
+ attr_reader :order_field
17
+
18
+ # @return ['asc', 'desc'] The direction of the order.
19
+ attr_reader :order_direction
20
+
21
+ # @return [Hash] The filters to apply to the query.
22
+ attr_reader :filters
23
+
24
+ def initialize(method, url)
25
+ super(method, url)
26
+
27
+ @query ||= {}
28
+ @filters ||= {}
29
+ end
30
+
31
+ # @param page [Integer,String] Set the page to fetch
32
+ # @return [KazeClient::Utils::ListRequest] self (to chain methods)
33
+ def add_page(page)
34
+ # Ensure the +per_page+ parameter is valid; default is 1
35
+ @page = if !page.is_a?(Numeric) || page.to_i < 1
36
+ 1
37
+ else
38
+ page
39
+ end
40
+
41
+ @query[:page] = @page
42
+
43
+ self
44
+ end
45
+
46
+ # @param per_page [Integer,String] Set the number of items to fetch per page
47
+ # @return [KazeClient::Utils::ListRequest] self (to chain methods)
48
+ def add_per_page(per_page)
49
+ # Ensure the +per_page+ parameter is between 1 and 100
50
+ @per_page = if !per_page.is_a?(Numeric) || per_page.to_i < 1
51
+ 1
52
+ elsif per_page > 100
53
+ 100
54
+ else
55
+ per_page
56
+ end
57
+
58
+ @query[:per_page] = @per_page
59
+
60
+ self
61
+ end
62
+
63
+ # @param field [String] Set the field to use for the list order
64
+ # @return [KazeClient::Utils::ListRequest] self (to chain methods)
65
+ def add_order_field(field)
66
+ @order_field = field
67
+ @query[:order_field] = @order_field
68
+
69
+ self
70
+ end
71
+
72
+ # @param direction ['asc','desc'] Set the direction of the order.
73
+ # @return [KazeClient::Utils::ListRequest] self (to chain methods)
74
+ def add_order_direction(direction)
75
+ # Ensure the +direction+ parameter is valid; default direction is ascendant
76
+ @order_direction = %w[asc desc].include?(direction.to_s) ? direction.to_s : 'asc'
77
+
78
+ @query[:order_direction] = @order_direction
79
+
80
+ self
81
+ end
82
+
83
+ # @!method filter_by_id(value)
84
+ # This is an example. Any method beginning with +filter_by_+ is valid and defined using
85
+ # +method_missing+. This adds a filter on the string following +filter_by_+ to the query.
86
+ # @param value [String] Add a filter to the query.
87
+ # @return [KazeClient::Utils::ListRequest] self (to chain methods)
88
+ # @example To filter on id then on name
89
+ # filter_by_id(2).filter_by_name('foo')
90
+ def method_missing(method_name, *args, &block)
91
+ match_data = method_name.match(/^filter_by_(\w+)/)
92
+
93
+ # Match_data[0] is the whole match while match_data[1] is the first capture group; here
94
+ # it is the field to filter on.
95
+ # Only the first given argument is considered to be the value to filter on. Possible
96
+ # subsequent arguments are ignored.
97
+ match_data ? filter_by(match_data[1], args[0]) : super
98
+ end
99
+
100
+ def respond_to_missing?(method_name, include_private = false)
101
+ method_name.match?(/^filter_by_/) || super
102
+ end
103
+
104
+ private
105
+
106
+ def filter_by(field, value)
107
+ # Initialize the filters Hash if needed
108
+ # @filters ||= {}
109
+
110
+ # Store the filter
111
+ @filters[field] = value
112
+
113
+ # Set the filter on the query parameters
114
+ @query["filter[#{field}]"] = value
115
+
116
+ self
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The base request object - for custom/newest APIs
4
+ require_relative 'request/request'
5
+
6
+ # Modules included in requests
7
+ require_relative 'request/requests/utils/authentified_request'
8
+ require_relative 'request/requests/utils/list_request'
9
+
10
+ # The base object for pre-crafted requests
11
+ require_relative 'request/requests/utils/final_request'
12
+
13
+ # The pre-crafted requests
14
+ require_relative 'request/requests/assign_performer_request'
15
+ require_relative 'request/requests/partners_request'
16
+ require_relative 'request/requests/create_job_request'
17
+ require_relative 'request/requests/job_request'
18
+ require_relative 'request/requests/job_workflow_request'
19
+ require_relative 'request/requests/job_workflows_request'
20
+ require_relative 'request/requests/jobs_request'
21
+ require_relative 'request/requests/login_request'
22
+ require_relative 'request/requests/profile_request'
23
+ require_relative 'request/requests/update_template_request'