cirro-ruby-client 1.0.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0fbe216e1f99f00cbe0816f9286960f5ba85335a287bef40971113cc6af06d2
4
- data.tar.gz: e4d958b0906bff2a9db8d21467145d461772f80f652b229c0d845a4b0d6c5c8d
3
+ metadata.gz: af3baedbf5539e9ad9f959866058793297fa577636b8b1d0668546feab80f4f5
4
+ data.tar.gz: 2a9fd6c37c1cb04385bf45fa20dd747909d92d472264d993221e31d7f1627b70
5
5
  SHA512:
6
- metadata.gz: bafe646924a4152758f62c9db242ed3fa76ce8c44a711e325a59f4ce7baabf8290a5adbc96aa5c8fbd0259e6b444fde3d0bff68acbbb1c5e54467edcb11f725b
7
- data.tar.gz: 2bfe4d104223034dbc9f5ed82434ccf3e6ddd42dcc06cfded2da855b460e5a7c642df4d9c4b2c621b77f679716d015f3068f473522a8fdb143074232374f1fcd
6
+ metadata.gz: be7b514feca8a7afab9a31d99dd52a31ae837cb0586965673874472ac04d025d4ee8212eaedac8032863f80d59415c1a065fd262230804a33325092c9394fa23
7
+ data.tar.gz: a7a56b0ff10355836c1abe9ba293921052011b62eb2f1ff7ba302e68fa212e5eea5a8b5599fd226383d4100243fe2d0aab601d7636763883b5639487321d7638
@@ -1,16 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cirro-ruby-client (0.1.3)
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.3)
12
- activesupport (= 6.0.3.3)
13
- activesupport (6.0.3.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)
@@ -25,14 +26,15 @@ GEM
25
26
  diff-lcs (1.4.4)
26
27
  faker (2.14.0)
27
28
  i18n (>= 1.6, < 2)
28
- faraday (1.0.1)
29
+ faraday (1.1.0)
29
30
  multipart-post (>= 1.2, < 3)
31
+ ruby2_keywords
30
32
  faraday_middleware (1.0.0)
31
33
  faraday (~> 1.0)
32
34
  hashdiff (1.0.1)
33
35
  i18n (1.8.5)
34
36
  concurrent-ruby (~> 1.0)
35
- json_api_client (1.17.1)
37
+ json_api_client (1.18.0)
36
38
  activemodel (>= 3.2.0)
37
39
  activesupport (>= 3.2.0)
38
40
  addressable (~> 2.2)
@@ -82,15 +84,16 @@ GEM
82
84
  rubocop-rspec (1.43.2)
83
85
  rubocop (~> 0.87)
84
86
  ruby-progressbar (1.10.1)
87
+ ruby2_keywords (0.0.2)
85
88
  thread_safe (0.3.6)
86
- tzinfo (1.2.7)
89
+ tzinfo (1.2.8)
87
90
  thread_safe (~> 0.1)
88
91
  unicode-display_width (1.7.0)
89
92
  webmock (3.9.1)
90
93
  addressable (>= 2.3.6)
91
94
  crack (>= 0.3.2)
92
95
  hashdiff (>= 0.4.0, < 2.0.0)
93
- zeitwerk (2.4.0)
96
+ zeitwerk (2.4.2)
94
97
 
95
98
  PLATFORMS
96
99
  ruby
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
 
28
28
  spec.add_runtime_dependency 'jwt'
29
+ spec.add_runtime_dependency 'faraday_middleware'
29
30
  spec.add_runtime_dependency 'json_api_client'
30
31
  end
@@ -1,11 +1,18 @@
1
1
  require 'json_api_client'
2
+
2
3
  require 'cirro_io/client/version'
3
4
  require 'cirro_io/client/configuration'
4
5
  require 'cirro_io/client/response_debugging_middleware'
5
6
  require 'cirro_io/client/jwt_authentication'
6
7
  require 'cirro_io/client/base'
8
+ require 'cirro_io/client/gig_invitation'
7
9
  require 'cirro_io/client/app_user'
8
10
  require 'cirro_io/client/app_worker'
11
+ require 'cirro_io/client/worker_invitation_filter'
12
+ require 'cirro_io/client/gig_task'
13
+ require 'cirro_io/client/gig_result'
14
+ require 'cirro_io/client/gig_time_activity'
15
+ require 'cirro_io/client/gig'
9
16
 
10
17
  module CirroIO
11
18
  module Client
@@ -1,9 +1,6 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class AppUser < Base
4
- def self.resource_name
5
- 'app-users'
6
- end
7
4
  end
8
5
  end
9
6
  end
@@ -2,10 +2,7 @@ module CirroIO
2
2
  module Client
3
3
  class AppWorker < Base
4
4
  has_one :app_user
5
-
6
- def self.resource_name
7
- 'app-workers'
8
- end
5
+ has_many :gig_invitations
9
6
  end
10
7
  end
11
8
  end
@@ -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,6 @@
1
+ module CirroIO
2
+ module Client
3
+ class GigInvitation < Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module CirroIO
2
+ module Client
3
+ class GigResult < Base
4
+ has_one :app_worker
5
+ has_one :gig_task
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module CirroIO
2
+ module Client
3
+ class GigTask < Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module CirroIO
2
+ module Client
3
+ class GigTimeActivity < Base
4
+ has_one :app_worker
5
+ end
6
+ end
7
+ end
@@ -3,7 +3,7 @@ module CirroIO
3
3
  module Client
4
4
  class ResponseDebuggingMiddleware < Faraday::Response::Middleware
5
5
  def on_complete(env)
6
- # binding.pry
6
+ binding.pry # rubocop:disable Lint/Debugger
7
7
  end
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  # rubocop:disable Style/MutableConstant
2
2
  module CirroIO
3
3
  module Client
4
- VERSION = '1.0.0'
4
+ VERSION = '1.2.2'
5
5
  end
6
6
  end
7
7
  # rubocop:enable Style/MutableConstant
@@ -0,0 +1,6 @@
1
+ module CirroIO
2
+ module Client
3
+ class WorkerInvitationFilter < Base
4
+ end
5
+ end
6
+ 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: 1.0.0
4
+ version: 1.2.2
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-10-14 00:00:00.000000000 Z
11
+ date: 2020-12-03 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
@@ -65,9 +79,15 @@ files:
65
79
  - lib/cirro_io/client/app_worker.rb
66
80
  - lib/cirro_io/client/base.rb
67
81
  - lib/cirro_io/client/configuration.rb
82
+ - lib/cirro_io/client/gig.rb
83
+ - lib/cirro_io/client/gig_invitation.rb
84
+ - lib/cirro_io/client/gig_result.rb
85
+ - lib/cirro_io/client/gig_task.rb
86
+ - lib/cirro_io/client/gig_time_activity.rb
68
87
  - lib/cirro_io/client/jwt_authentication.rb
69
88
  - lib/cirro_io/client/response_debugging_middleware.rb
70
89
  - lib/cirro_io/client/version.rb
90
+ - lib/cirro_io/client/worker_invitation_filter.rb
71
91
  homepage: https://cirro.io/api-docs/v1#cirro-api-documentation
72
92
  licenses:
73
93
  - MIT