cirro-ruby-client 1.2.1 → 1.5.0

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: ae8201867c4e81773872690ee39df951dfb161d68cdf4ab10807a497a8e2744b
4
- data.tar.gz: 59b06b8045b93026ddae29649542f54398ecc5c8fd5eb727608709153bcd57ea
3
+ metadata.gz: b40b51067875bc8f05dbf8d6d3ef70713369437b84f7f02d34ad9ebc12e6f1f5
4
+ data.tar.gz: 95d7598c00eb3ad3fcd7d2c357252620792dde5653ef3ca6a002753c2a9a5c91
5
5
  SHA512:
6
- metadata.gz: 6e664faa51a535dec4b7544c5bd43870e31dfa014d3f5e8665df7c20f4a6fa075529b226ae9835276105e229a86ab020cdfc005662bc5f972d587a43cba40515
7
- data.tar.gz: f3263a656d9d2cc6500233dafdd40d47dee4727a3d1d1b4e9f464a4ecdc4e2c399b8a728360061b498f32dc77c30dfed40515560ce8b33ad01bdd6031b002861
6
+ metadata.gz: aa7585fece3356f8511010df5f8b7635946da195b66350dd10cd7d0c964b18616ad53291ee12f287d37819666f73098569b550b8c6e9a6568a9d8b37edd230fc
7
+ data.tar.gz: 4c4bb7c02b948a2a8786be6e622aaf5dac1ef9cc1fe046cee66dd15cafaa3f2d27595e1749e014d186ae72987108c79a277e08eeced5bdfa5e42756053b4e012
data/Gemfile.lock CHANGED
@@ -1,22 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cirro-ruby-client (1.2.1)
4
+ cirro-ruby-client (1.5.0)
5
+ faraday (< 1.2.0)
5
6
  faraday_middleware
6
- json_api_client
7
+ json_api_client (>= 1.10.0)
7
8
  jwt
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activemodel (6.0.3.4)
13
- activesupport (= 6.0.3.4)
14
- activesupport (6.0.3.4)
13
+ activemodel (6.1.3.2)
14
+ activesupport (= 6.1.3.2)
15
+ activesupport (6.1.3.2)
15
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
- i18n (>= 0.7, < 2)
17
- minitest (~> 5.1)
18
- tzinfo (~> 1.1)
19
- zeitwerk (~> 2.2, >= 2.2.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
20
21
  addressable (2.7.0)
21
22
  public_suffix (>= 2.0.2, < 5.0)
22
23
  ast (2.4.1)
@@ -34,16 +35,16 @@ GEM
34
35
  hashdiff (1.0.1)
35
36
  i18n (1.8.5)
36
37
  concurrent-ruby (~> 1.0)
37
- json_api_client (1.17.1)
38
+ json_api_client (1.18.0)
38
39
  activemodel (>= 3.2.0)
39
40
  activesupport (>= 3.2.0)
40
41
  addressable (~> 2.2)
41
42
  faraday (>= 0.15.2, < 1.2.0)
42
43
  faraday_middleware (>= 0.9.0, < 1.2.0)
43
44
  rack (>= 0.2)
44
- jwt (2.2.2)
45
+ jwt (2.2.3)
45
46
  method_source (1.0.0)
46
- minitest (5.14.2)
47
+ minitest (5.14.4)
47
48
  multipart-post (2.1.1)
48
49
  parallel (1.19.2)
49
50
  parser (2.7.2.0)
@@ -84,10 +85,9 @@ GEM
84
85
  rubocop-rspec (1.43.2)
85
86
  rubocop (~> 0.87)
86
87
  ruby-progressbar (1.10.1)
87
- ruby2_keywords (0.0.2)
88
- thread_safe (0.3.6)
89
- tzinfo (1.2.8)
90
- thread_safe (~> 0.1)
88
+ ruby2_keywords (0.0.4)
89
+ tzinfo (2.0.4)
90
+ concurrent-ruby (~> 1.0)
91
91
  unicode-display_width (1.7.0)
92
92
  webmock (3.9.1)
93
93
  addressable (>= 2.3.6)
data/README.md CHANGED
@@ -43,3 +43,15 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
43
43
  ## License
44
44
 
45
45
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+
47
+ ## Usage
48
+
49
+ #### Bulk create gig invitations
50
+
51
+ ```ruby
52
+ gig = CirroIO::Client::Gig.load(id: 1)
53
+ filter = CirroIO::Client::WorkerFilter.new(filter_query: '{ "app_worker_id": { "$in": [1,2,3] } }')
54
+ invitation = CirroIO::Client::GigInvitation.new(gig: gig)
55
+
56
+ invitation.bulk_create_with(filter, auto_accept: true) # by default auto_accept is false
57
+ ```
@@ -26,6 +26,7 @@ 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', '< 1.2.0'
29
30
  spec.add_runtime_dependency 'faraday_middleware'
30
- spec.add_runtime_dependency 'json_api_client'
31
+ spec.add_runtime_dependency 'json_api_client', '>= 1.10.0'
31
32
  end
@@ -1,23 +1,20 @@
1
1
  require 'json_api_client'
2
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
-
8
3
  require 'cirro_io/client/version'
9
4
  require 'cirro_io/client/configuration'
10
5
  require 'cirro_io/client/response_debugging_middleware'
11
6
  require 'cirro_io/client/jwt_authentication'
12
7
  require 'cirro_io/client/base'
8
+ require 'cirro_io/client/bulk_action_helper'
13
9
  require 'cirro_io/client/gig_invitation'
14
10
  require 'cirro_io/client/app_user'
15
11
  require 'cirro_io/client/app_worker'
16
- require 'cirro_io/client/worker_invitation_filter'
12
+ require 'cirro_io/client/worker_filter'
17
13
  require 'cirro_io/client/gig_task'
18
14
  require 'cirro_io/client/gig_result'
19
15
  require 'cirro_io/client/gig_time_activity'
20
16
  require 'cirro_io/client/gig'
17
+ require 'cirro_io/client/payout'
21
18
 
22
19
  module CirroIO
23
20
  module Client
@@ -3,6 +3,7 @@ module CirroIO
3
3
  class AppWorker < Base
4
4
  has_one :app_user
5
5
  has_many :gig_invitations
6
+ has_many :payouts
6
7
  end
7
8
  end
8
9
  end
@@ -4,10 +4,16 @@ module CirroIO
4
4
  self.route_format = :dasherized_route
5
5
  self.json_key_format = :dasherized_key
6
6
 
7
- # https://github.com/JsonApiClient/json_api_client/issues/215
7
+ # HACK: https://github.com/JsonApiClient/json_api_client/issues/215
8
+ # Used for initialization as well
8
9
  def self.site=(url)
9
- super(url)
10
- connection.faraday.url_prefix = url
10
+ super.tap do
11
+ connection true do |connection|
12
+ connection.use JwtAuthentication
13
+ connection.use Faraday::Response::Logger
14
+ # connection.use ResponseDebuggingMiddleware # for debugging or while adding new specs
15
+ end
16
+ end
11
17
  end
12
18
 
13
19
  def self.custom_post(endpoint, payload)
@@ -25,9 +31,3 @@ module CirroIO
25
31
  end
26
32
  end
27
33
  end
28
-
29
- CirroIO::Client::Base.connection do |connection|
30
- connection.use CirroIO::Client::JwtAuthentication
31
- connection.use Faraday::Response::Logger
32
- # connection.use CirroIO::Client::ResponseDebuggingMiddleware # This middleware can be injected during debugging or while adding new specs
33
- end
@@ -0,0 +1,9 @@
1
+ module CirroIO
2
+ module Client
3
+ module BulkActionHelper
4
+ def format_to_dashed_keys(params)
5
+ params.deep_transform_keys { |key| key.to_s.gsub('_', '-') }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,16 +1,18 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class Gig < Base
4
- has_one :worker_invitation_filter
4
+ include CirroIO::Client::BulkActionHelper
5
+
6
+ has_one :worker_filter
5
7
  has_many :gig_tasks
6
8
  has_many :gig_results
7
9
  has_many :gig_time_activities
8
10
 
9
11
  # rubocop:disable Metrics/AbcSize
10
- def bulk_create_with(worker_invitation_filter, gig_tasks)
12
+ def bulk_create_with(worker_filter, gig_tasks)
11
13
  payload = { data: { attributes: attributes, relationships: {} } }
12
14
  payload[:data][:relationships][:gig_tasks] = gig_tasks.map(&:attributes)
13
- payload[:data][:relationships][:worker_invitation_filter] = worker_invitation_filter.attributes
15
+ payload[:data][:relationships][:worker_filter] = worker_filter.attributes
14
16
 
15
17
  response = self.class.custom_post('bulk/gigs', format_to_dashed_keys(payload))
16
18
 
@@ -34,12 +36,6 @@ module CirroIO
34
36
  self.class.parser.parse(self.class, response).first
35
37
  end
36
38
  # 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
39
  end
44
40
  end
45
41
  end
@@ -1,6 +1,17 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class GigInvitation < Base
4
+ include CirroIO::Client::BulkActionHelper
5
+
6
+ has_one :gig
7
+
8
+ def bulk_create_with(worker_filter, auto_accept: false)
9
+ payload = { data: { attributes: attributes.merge(worker_filter: worker_filter.attributes, auto_accept: auto_accept) } }
10
+
11
+ response = self.class.custom_post("bulk/gigs/#{gig.id}/gig_invitations", format_to_dashed_keys(payload))
12
+
13
+ self.class.parser.parse(self.class, response)
14
+ end
4
15
  end
5
16
  end
6
17
  end
@@ -0,0 +1,7 @@
1
+ module CirroIO
2
+ module Client
3
+ class Payout < Base
4
+ has_one :app_worker
5
+ end
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  # rubocop:disable Style/MutableConstant
2
2
  module CirroIO
3
3
  module Client
4
- VERSION = '1.2.1'
4
+ VERSION = '1.5.0'
5
5
  end
6
6
  end
7
7
  # rubocop:enable Style/MutableConstant
@@ -1,6 +1,6 @@
1
1
  module CirroIO
2
2
  module Client
3
- class WorkerInvitationFilter < Base
3
+ class WorkerFilter < Base
4
4
  end
5
5
  end
6
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.2.1
4
+ version: 1.5.0
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-12-02 00:00:00.000000000 Z
11
+ date: 2021-06-09 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
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "<"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: faraday_middleware
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
61
+ version: 1.10.0
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: 1.10.0
55
69
  description: Simple wrapper for Cirro API
56
70
  email:
57
71
  - OrgtestIODevelopers@epam.com
@@ -74,11 +88,11 @@ files:
74
88
  - bin/console
75
89
  - bin/setup
76
90
  - cirro-ruby-client.gemspec
77
- - lib/cirro_io/base_association.rb
78
91
  - lib/cirro_io/client.rb
79
92
  - lib/cirro_io/client/app_user.rb
80
93
  - lib/cirro_io/client/app_worker.rb
81
94
  - lib/cirro_io/client/base.rb
95
+ - lib/cirro_io/client/bulk_action_helper.rb
82
96
  - lib/cirro_io/client/configuration.rb
83
97
  - lib/cirro_io/client/gig.rb
84
98
  - lib/cirro_io/client/gig_invitation.rb
@@ -86,10 +100,10 @@ files:
86
100
  - lib/cirro_io/client/gig_task.rb
87
101
  - lib/cirro_io/client/gig_time_activity.rb
88
102
  - lib/cirro_io/client/jwt_authentication.rb
103
+ - lib/cirro_io/client/payout.rb
89
104
  - lib/cirro_io/client/response_debugging_middleware.rb
90
105
  - lib/cirro_io/client/version.rb
91
- - lib/cirro_io/client/worker_invitation_filter.rb
92
- - lib/cirro_io/has_one.rb
106
+ - lib/cirro_io/client/worker_filter.rb
93
107
  homepage: https://cirro.io/api-docs/v1#cirro-api-documentation
94
108
  licenses:
95
109
  - MIT
@@ -1,33 +0,0 @@
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
@@ -1,16 +0,0 @@
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