cirro-ruby-client 1.2.3 → 1.6.1

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: dcb633e6af68286109c3f5329c596be38609e12bfc74f8db3532b62b5d7a198a
4
- data.tar.gz: 1043a463fdd431cf96fb4abe6c85de402c3c39c00056c830eb701457f0a2f246
3
+ metadata.gz: e6890f4b343eb4c3efc64fe9f75c644c7d706e9c19bae033d367e4aa0fd99987
4
+ data.tar.gz: a84440266927041fc001db93c57c44bcf65ef0a2d16b87b2ccc443e1af041564
5
5
  SHA512:
6
- metadata.gz: 19b4504bb063bcf4ba2575c785928c7cc7a5b358e10fbf5bb17a39a5dd1b0b5b647e416c4450686682cf5e78ee88a62dbdcb452fc0a4e053731a4a2aaa406f67
7
- data.tar.gz: bddcf4a2f30da9ae1e6ba56a1099b57957f50cefeb642e226e08ae974f756d3a874b739380732f3d937e7b9f5386639c4046903ffddd766b294c26d1ed24f2d4
6
+ metadata.gz: 6ed00bfa6f1d74f95338c6537b8da72754c6c48ecf8d93078891120f8f7be94fba74b0f929646594da35d79583aea4ff6f15ff31ac096dee6663037ebd953640
7
+ data.tar.gz: 1348492e075def7497a2734e170a3f8453fd1ef150b5473dc515e6dbcc0ede4c4612e0cf58edce08cdc65e293f31f7bf4f5e1a46f65155285a9f8514f77c0339
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.6.1)
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)
@@ -41,9 +42,9 @@ GEM
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
+ ```
@@ -5,14 +5,19 @@ require 'cirro_io/client/configuration'
5
5
  require 'cirro_io/client/response_debugging_middleware'
6
6
  require 'cirro_io/client/jwt_authentication'
7
7
  require 'cirro_io/client/base'
8
+ require 'cirro_io/client/bulk_action_helper'
8
9
  require 'cirro_io/client/gig_invitation'
9
10
  require 'cirro_io/client/app_user'
10
11
  require 'cirro_io/client/app_worker'
11
- require 'cirro_io/client/worker_invitation_filter'
12
+ require 'cirro_io/client/worker_filter'
12
13
  require 'cirro_io/client/gig_task'
13
14
  require 'cirro_io/client/gig_result'
14
15
  require 'cirro_io/client/gig_time_activity'
15
16
  require 'cirro_io/client/gig'
17
+ require 'cirro_io/client/payout'
18
+ require 'cirro_io/client/notifications_broadcast'
19
+ require 'cirro_io/client/notifications_channel'
20
+ require 'cirro_io/client/notifications_template'
16
21
 
17
22
  module CirroIO
18
23
  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,18 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class GigInvitation < Base
4
+ include CirroIO::Client::BulkActionHelper
5
+
6
+ has_one :gig
7
+ has_one :app_worker
8
+
9
+ def bulk_create_with(worker_filter, auto_accept: false)
10
+ payload = { data: { attributes: attributes.merge(worker_filter: worker_filter.attributes, auto_accept: auto_accept) } }
11
+
12
+ response = self.class.custom_post("bulk/gigs/#{gig.id}/gig_invitations", format_to_dashed_keys(payload))
13
+
14
+ self.class.parser.parse(self.class, response)
15
+ end
4
16
  end
5
17
  end
6
18
  end
@@ -1,6 +1,7 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class GigTask < Base
4
+ has_one :gig
4
5
  end
5
6
  end
6
7
  end
@@ -1,6 +1,7 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class GigTimeActivity < Base
4
+ has_one :gig
4
5
  has_one :app_worker
5
6
  end
6
7
  end
@@ -0,0 +1,8 @@
1
+ module CirroIO
2
+ module Client
3
+ class NotificationsBroadcast < Base
4
+ has_one :channel, class_name: 'NotificationsChannel'
5
+ has_one :worker_filter
6
+ end
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  module CirroIO
2
2
  module Client
3
- class WorkerInvitationFilter < Base
3
+ class NotificationsChannel < Base
4
4
  end
5
5
  end
6
6
  end
@@ -0,0 +1,7 @@
1
+ module CirroIO
2
+ module Client
3
+ class NotificationsTemplate < Base
4
+ has_one :channel, class_name: 'NotificationsChannel'
5
+ end
6
+ end
7
+ 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.3'
4
+ VERSION = '1.6.1'
5
5
  end
6
6
  end
7
7
  # rubocop:enable Style/MutableConstant
@@ -0,0 +1,6 @@
1
+ module CirroIO
2
+ module Client
3
+ class WorkerFilter < 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.2.3
4
+ version: 1.6.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: 2021-01-16 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -92,6 +92,7 @@ files:
92
92
  - lib/cirro_io/client/app_user.rb
93
93
  - lib/cirro_io/client/app_worker.rb
94
94
  - lib/cirro_io/client/base.rb
95
+ - lib/cirro_io/client/bulk_action_helper.rb
95
96
  - lib/cirro_io/client/configuration.rb
96
97
  - lib/cirro_io/client/gig.rb
97
98
  - lib/cirro_io/client/gig_invitation.rb
@@ -99,9 +100,13 @@ files:
99
100
  - lib/cirro_io/client/gig_task.rb
100
101
  - lib/cirro_io/client/gig_time_activity.rb
101
102
  - lib/cirro_io/client/jwt_authentication.rb
103
+ - lib/cirro_io/client/notifications_broadcast.rb
104
+ - lib/cirro_io/client/notifications_channel.rb
105
+ - lib/cirro_io/client/notifications_template.rb
106
+ - lib/cirro_io/client/payout.rb
102
107
  - lib/cirro_io/client/response_debugging_middleware.rb
103
108
  - lib/cirro_io/client/version.rb
104
- - lib/cirro_io/client/worker_invitation_filter.rb
109
+ - lib/cirro_io/client/worker_filter.rb
105
110
  homepage: https://cirro.io/api-docs/v1#cirro-api-documentation
106
111
  licenses:
107
112
  - MIT