kaze_client 0.1.1
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/.github/workflows/main.yml +18 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +104 -0
- data/CHANGELOG.md +11 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/kaze_client.gemspec +35 -0
- data/lib/activesupport/blank.rb +155 -0
- data/lib/activesupport/camelize.rb +32 -0
- data/lib/kaze_client/client.rb +99 -0
- data/lib/kaze_client/error/disabled_account.rb +13 -0
- data/lib/kaze_client/error/forbidden.rb +13 -0
- data/lib/kaze_client/error/generic.rb +29 -0
- data/lib/kaze_client/error/internal_server_error.rb +13 -0
- data/lib/kaze_client/error/invalid_credentials.rb +13 -0
- data/lib/kaze_client/error/no_endpoint.rb +19 -0
- data/lib/kaze_client/error/no_private_token.rb +13 -0
- data/lib/kaze_client/error/not_found.rb +13 -0
- data/lib/kaze_client/error/unauthorized.rb +13 -0
- data/lib/kaze_client/errors.rb +12 -0
- data/lib/kaze_client/request/request.rb +113 -0
- data/lib/kaze_client/request/requests/assign_performer_request.rb +23 -0
- data/lib/kaze_client/request/requests/companies_request.rb +19 -0
- data/lib/kaze_client/request/requests/create_job_request.rb +32 -0
- data/lib/kaze_client/request/requests/job_request.rb +17 -0
- data/lib/kaze_client/request/requests/job_workflow_request.rb +25 -0
- data/lib/kaze_client/request/requests/job_workflows_request.rb +19 -0
- data/lib/kaze_client/request/requests/jobs_request.rb +18 -0
- data/lib/kaze_client/request/requests/login_request.rb +28 -0
- data/lib/kaze_client/request/requests/profile_request.rb +17 -0
- data/lib/kaze_client/request/requests/update_template_request.rb +19 -0
- data/lib/kaze_client/request/requests/utils/authentified_request.rb +25 -0
- data/lib/kaze_client/request/requests/utils/final_request.rb +13 -0
- data/lib/kaze_client/request/requests/utils/list_request.rb +120 -0
- data/lib/kaze_client/requests.rb +23 -0
- data/lib/kaze_client/response.rb +34 -0
- data/lib/kaze_client/version.rb +5 -0
- data/lib/kaze_client.rb +17 -0
- metadata +114 -0
@@ -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/companies_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"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KazeClient
|
4
|
+
# @author ciappa_m@modulotech.fr
|
5
|
+
# Represents response from a Kaze API
|
6
|
+
# @see KazeClient::Client
|
7
|
+
# @see KazeClient::Request
|
8
|
+
# @since 0.1.0
|
9
|
+
class Response
|
10
|
+
# @return [HTTParty::Response] The response object from HTTParty call
|
11
|
+
attr_reader :original_response
|
12
|
+
|
13
|
+
# @return [Hash] The JSON object resulting from HTTParty parsed response
|
14
|
+
attr_reader :parsed_response
|
15
|
+
|
16
|
+
# @param response [HTTParty::Response] The response object from HTTParty call
|
17
|
+
def initialize(response)
|
18
|
+
@original_response = response
|
19
|
+
@parsed_response = response.parsed_response
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(method_name, *args, &block)
|
23
|
+
if %i[original_response parsed_response].include?(method_name)
|
24
|
+
send(method_name)
|
25
|
+
else
|
26
|
+
@parsed_response.send(method_name, *args, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def respond_to_missing?(method_name, include_private = false)
|
31
|
+
%i[original_response parsed_response].include?(method_name) || super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/kaze_client.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# I only need some very specific parts of activesupport.
|
4
|
+
require "activesupport/blank"
|
5
|
+
require "activesupport/camelize"
|
6
|
+
|
7
|
+
# Require HTTParty
|
8
|
+
require "httparty"
|
9
|
+
|
10
|
+
# Require the version number
|
11
|
+
require_relative "kaze_client/version"
|
12
|
+
|
13
|
+
# Require the different parts of the gem
|
14
|
+
require_relative "kaze_client/errors"
|
15
|
+
require_relative "kaze_client/requests"
|
16
|
+
require_relative "kaze_client/response"
|
17
|
+
require_relative "kaze_client/client"
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kaze_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthieu Ciappara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.18'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.18.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.18'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.18.1
|
33
|
+
description: |
|
34
|
+
This is the official Ruby client library for Kaze (https://www.kaze.so/) API.
|
35
|
+
|
36
|
+
The API documentation can be found at https://documenter.getpostman.com/view/15303175/U16nLQ7r.
|
37
|
+
email:
|
38
|
+
- ciappa_m@modulotech.fr
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- ".github/workflows/main.yml"
|
44
|
+
- ".gitignore"
|
45
|
+
- ".rspec"
|
46
|
+
- ".rubocop.yml"
|
47
|
+
- CHANGELOG.md
|
48
|
+
- CODE_OF_CONDUCT.md
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- kaze_client.gemspec
|
57
|
+
- lib/activesupport/blank.rb
|
58
|
+
- lib/activesupport/camelize.rb
|
59
|
+
- lib/kaze_client.rb
|
60
|
+
- lib/kaze_client/client.rb
|
61
|
+
- lib/kaze_client/error/disabled_account.rb
|
62
|
+
- lib/kaze_client/error/forbidden.rb
|
63
|
+
- lib/kaze_client/error/generic.rb
|
64
|
+
- lib/kaze_client/error/internal_server_error.rb
|
65
|
+
- lib/kaze_client/error/invalid_credentials.rb
|
66
|
+
- lib/kaze_client/error/no_endpoint.rb
|
67
|
+
- lib/kaze_client/error/no_private_token.rb
|
68
|
+
- lib/kaze_client/error/not_found.rb
|
69
|
+
- lib/kaze_client/error/unauthorized.rb
|
70
|
+
- lib/kaze_client/errors.rb
|
71
|
+
- lib/kaze_client/request/request.rb
|
72
|
+
- lib/kaze_client/request/requests/assign_performer_request.rb
|
73
|
+
- lib/kaze_client/request/requests/companies_request.rb
|
74
|
+
- lib/kaze_client/request/requests/create_job_request.rb
|
75
|
+
- lib/kaze_client/request/requests/job_request.rb
|
76
|
+
- lib/kaze_client/request/requests/job_workflow_request.rb
|
77
|
+
- lib/kaze_client/request/requests/job_workflows_request.rb
|
78
|
+
- lib/kaze_client/request/requests/jobs_request.rb
|
79
|
+
- lib/kaze_client/request/requests/login_request.rb
|
80
|
+
- lib/kaze_client/request/requests/profile_request.rb
|
81
|
+
- lib/kaze_client/request/requests/update_template_request.rb
|
82
|
+
- lib/kaze_client/request/requests/utils/authentified_request.rb
|
83
|
+
- lib/kaze_client/request/requests/utils/final_request.rb
|
84
|
+
- lib/kaze_client/request/requests/utils/list_request.rb
|
85
|
+
- lib/kaze_client/requests.rb
|
86
|
+
- lib/kaze_client/response.rb
|
87
|
+
- lib/kaze_client/version.rb
|
88
|
+
homepage: https://github.com/moduloTech/kaze_client
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata:
|
92
|
+
homepage_uri: https://github.com/moduloTech/kaze_client
|
93
|
+
source_code_uri: https://github.com/moduloTech/kaze_client
|
94
|
+
changelog_uri: https://github.com/moduloTech/kaze_client/blob/master/CHANGELOG.md
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.5.0
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubygems_version: 3.0.3.1
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: This is the official Ruby client library for Kaze API.
|
114
|
+
test_files: []
|