cirro-ruby-client 0.1.3 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +13 -7
- data/cirro-ruby-client.gemspec +1 -0
- data/lib/cirro_io/base_association.rb +33 -0
- data/lib/cirro_io/client.rb +13 -0
- data/lib/cirro_io/client/app_user.rb +6 -0
- data/lib/cirro_io/client/app_worker.rb +2 -3
- data/lib/cirro_io/client/base.rb +13 -0
- data/lib/cirro_io/client/gig.rb +45 -0
- data/lib/cirro_io/client/gig_invitation.rb +6 -0
- data/lib/cirro_io/client/gig_result.rb +8 -0
- data/lib/cirro_io/client/gig_task.rb +6 -0
- data/lib/cirro_io/client/gig_time_activity.rb +7 -0
- data/lib/cirro_io/client/response_debugging_middleware.rb +1 -1
- data/lib/cirro_io/client/version.rb +1 -1
- data/lib/cirro_io/client/worker_invitation_filter.rb +6 -0
- data/lib/cirro_io/has_one.rb +16 -0
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae8201867c4e81773872690ee39df951dfb161d68cdf4ab10807a497a8e2744b
|
4
|
+
data.tar.gz: 59b06b8045b93026ddae29649542f54398ecc5c8fd5eb727608709153bcd57ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e664faa51a535dec4b7544c5bd43870e31dfa014d3f5e8665df7c20f4a6fa075529b226ae9835276105e229a86ab020cdfc005662bc5f972d587a43cba40515
|
7
|
+
data.tar.gz: f3263a656d9d2cc6500233dafdd40d47dee4727a3d1d1b4e9f464a4ecdc4e2c399b8a728360061b498f32dc77c30dfed40515560ce8b33ad01bdd6031b002861
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirro-ruby-client (
|
4
|
+
cirro-ruby-client (1.2.1)
|
5
|
+
faraday_middleware
|
5
6
|
json_api_client
|
6
7
|
jwt
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
activemodel (6.0.3.
|
12
|
-
activesupport (= 6.0.3.
|
13
|
-
activesupport (6.0.3.
|
12
|
+
activemodel (6.0.3.4)
|
13
|
+
activesupport (= 6.0.3.4)
|
14
|
+
activesupport (6.0.3.4)
|
14
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
16
|
i18n (>= 0.7, < 2)
|
16
17
|
minitest (~> 5.1)
|
@@ -23,8 +24,11 @@ GEM
|
|
23
24
|
concurrent-ruby (1.1.7)
|
24
25
|
crack (0.4.4)
|
25
26
|
diff-lcs (1.4.4)
|
26
|
-
|
27
|
+
faker (2.14.0)
|
28
|
+
i18n (>= 1.6, < 2)
|
29
|
+
faraday (1.1.0)
|
27
30
|
multipart-post (>= 1.2, < 3)
|
31
|
+
ruby2_keywords
|
28
32
|
faraday_middleware (1.0.0)
|
29
33
|
faraday (~> 1.0)
|
30
34
|
hashdiff (1.0.1)
|
@@ -80,21 +84,23 @@ GEM
|
|
80
84
|
rubocop-rspec (1.43.2)
|
81
85
|
rubocop (~> 0.87)
|
82
86
|
ruby-progressbar (1.10.1)
|
87
|
+
ruby2_keywords (0.0.2)
|
83
88
|
thread_safe (0.3.6)
|
84
|
-
tzinfo (1.2.
|
89
|
+
tzinfo (1.2.8)
|
85
90
|
thread_safe (~> 0.1)
|
86
91
|
unicode-display_width (1.7.0)
|
87
92
|
webmock (3.9.1)
|
88
93
|
addressable (>= 2.3.6)
|
89
94
|
crack (>= 0.3.2)
|
90
95
|
hashdiff (>= 0.4.0, < 2.0.0)
|
91
|
-
zeitwerk (2.4.
|
96
|
+
zeitwerk (2.4.2)
|
92
97
|
|
93
98
|
PLATFORMS
|
94
99
|
ruby
|
95
100
|
|
96
101
|
DEPENDENCIES
|
97
102
|
cirro-ruby-client!
|
103
|
+
faker
|
98
104
|
pry
|
99
105
|
rake (~> 12.0)
|
100
106
|
rspec (~> 3.0)
|
data/cirro-ruby-client.gemspec
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module JsonApiClient
|
2
|
+
module Associations
|
3
|
+
class BaseAssociation
|
4
|
+
attr_reader :attr_name, :klass, :options
|
5
|
+
def initialize(attr_name, klass, options = {})
|
6
|
+
@attr_name = attr_name
|
7
|
+
@klass = klass
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def association_class
|
12
|
+
@association_class ||= Utils.compute_type(klass, options.fetch(:class_name) do
|
13
|
+
attr_name.to_s.classify
|
14
|
+
end)
|
15
|
+
end
|
16
|
+
|
17
|
+
def data(url)
|
18
|
+
from_result_set(association_class.requestor.linked(url))
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_result_set(result_set)
|
22
|
+
result_set.to_a
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_records(data)
|
26
|
+
data.map do |d|
|
27
|
+
record_class = Utils.compute_type(klass, klass.key_formatter.unformat(d['type']).classify)
|
28
|
+
record_class.load id: d['id']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/cirro_io/client.rb
CHANGED
@@ -1,10 +1,23 @@
|
|
1
1
|
require 'json_api_client'
|
2
|
+
|
3
|
+
# temporary monkey patch code to fix gem bug
|
4
|
+
require 'cirro_io/has_one'
|
5
|
+
require 'cirro_io/base_association'
|
6
|
+
# temporary monkey patch code to fix gem bug
|
7
|
+
|
2
8
|
require 'cirro_io/client/version'
|
3
9
|
require 'cirro_io/client/configuration'
|
4
10
|
require 'cirro_io/client/response_debugging_middleware'
|
5
11
|
require 'cirro_io/client/jwt_authentication'
|
6
12
|
require 'cirro_io/client/base'
|
13
|
+
require 'cirro_io/client/gig_invitation'
|
14
|
+
require 'cirro_io/client/app_user'
|
7
15
|
require 'cirro_io/client/app_worker'
|
16
|
+
require 'cirro_io/client/worker_invitation_filter'
|
17
|
+
require 'cirro_io/client/gig_task'
|
18
|
+
require 'cirro_io/client/gig_result'
|
19
|
+
require 'cirro_io/client/gig_time_activity'
|
20
|
+
require 'cirro_io/client/gig'
|
8
21
|
|
9
22
|
module CirroIO
|
10
23
|
module Client
|
data/lib/cirro_io/client/base.rb
CHANGED
@@ -9,6 +9,19 @@ module CirroIO
|
|
9
9
|
super(url)
|
10
10
|
connection.faraday.url_prefix = url
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.custom_post(endpoint, payload)
|
14
|
+
custom_connection.post(endpoint, payload.to_json)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.custom_connection
|
18
|
+
Faraday.new(url: "#{CirroIO::Client.configuration.site}/#{CirroIO::Client.configuration.api_version}") do |conn|
|
19
|
+
conn.request :json
|
20
|
+
conn.response :json
|
21
|
+
conn.use CirroIO::Client::JwtAuthentication
|
22
|
+
conn.use JsonApiClient::Middleware::Status, {}
|
23
|
+
end
|
24
|
+
end
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module CirroIO
|
2
|
+
module Client
|
3
|
+
class Gig < Base
|
4
|
+
has_one :worker_invitation_filter
|
5
|
+
has_many :gig_tasks
|
6
|
+
has_many :gig_results
|
7
|
+
has_many :gig_time_activities
|
8
|
+
|
9
|
+
# rubocop:disable Metrics/AbcSize
|
10
|
+
def bulk_create_with(worker_invitation_filter, gig_tasks)
|
11
|
+
payload = { data: { attributes: attributes, relationships: {} } }
|
12
|
+
payload[:data][:relationships][:gig_tasks] = gig_tasks.map(&:attributes)
|
13
|
+
payload[:data][:relationships][:worker_invitation_filter] = worker_invitation_filter.attributes
|
14
|
+
|
15
|
+
response = self.class.custom_post('bulk/gigs', format_to_dashed_keys(payload))
|
16
|
+
|
17
|
+
self.class.parser.parse(self.class, response).first
|
18
|
+
end
|
19
|
+
|
20
|
+
def bulk_archive_with(gig_results, gig_time_activities)
|
21
|
+
payload = { data: { relationships: {} } }
|
22
|
+
payload[:data][:relationships][:gig_results] = gig_results.map do |result|
|
23
|
+
result.attributes.merge({ relationships: {
|
24
|
+
'app-worker': { data: result.app_worker.attributes },
|
25
|
+
'gig-task': { data: result.gig_task.attributes },
|
26
|
+
} })
|
27
|
+
end
|
28
|
+
payload[:data][:relationships][:gig_time_activities] = gig_time_activities.map do |activity|
|
29
|
+
activity.attributes.merge({ relationships: { 'app-worker': { data: activity.app_worker.attributes } } })
|
30
|
+
end
|
31
|
+
|
32
|
+
response = self.class.custom_post("bulk/gigs/#{id}/archive", format_to_dashed_keys(payload))
|
33
|
+
|
34
|
+
self.class.parser.parse(self.class, response).first
|
35
|
+
end
|
36
|
+
# rubocop:enable Metrics/AbcSize
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def format_to_dashed_keys(params)
|
41
|
+
params.deep_transform_keys { |key| key.to_s.gsub('_', '-') }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module JsonApiClient
|
2
|
+
module Associations
|
3
|
+
module HasOne
|
4
|
+
class Association < BaseAssociation
|
5
|
+
def from_result_set(result_set)
|
6
|
+
result_set.first
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_records(data)
|
10
|
+
record_class = Utils.compute_type(klass, klass.key_formatter.unformat(data['type']).classify)
|
11
|
+
record_class.load id: data['id']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cirro-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cirro Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: json_api_client
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,13 +74,22 @@ files:
|
|
60
74
|
- bin/console
|
61
75
|
- bin/setup
|
62
76
|
- cirro-ruby-client.gemspec
|
77
|
+
- lib/cirro_io/base_association.rb
|
63
78
|
- lib/cirro_io/client.rb
|
79
|
+
- lib/cirro_io/client/app_user.rb
|
64
80
|
- lib/cirro_io/client/app_worker.rb
|
65
81
|
- lib/cirro_io/client/base.rb
|
66
82
|
- lib/cirro_io/client/configuration.rb
|
83
|
+
- lib/cirro_io/client/gig.rb
|
84
|
+
- lib/cirro_io/client/gig_invitation.rb
|
85
|
+
- lib/cirro_io/client/gig_result.rb
|
86
|
+
- lib/cirro_io/client/gig_task.rb
|
87
|
+
- lib/cirro_io/client/gig_time_activity.rb
|
67
88
|
- lib/cirro_io/client/jwt_authentication.rb
|
68
89
|
- lib/cirro_io/client/response_debugging_middleware.rb
|
69
90
|
- lib/cirro_io/client/version.rb
|
91
|
+
- lib/cirro_io/client/worker_invitation_filter.rb
|
92
|
+
- lib/cirro_io/has_one.rb
|
70
93
|
homepage: https://cirro.io/api-docs/v1#cirro-api-documentation
|
71
94
|
licenses:
|
72
95
|
- MIT
|