cirro-ruby-client 2.5.11 → 2.5.12

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: 2ce81e7b0822c3a040876d798246e58e6e3c1d4d53ae65a00d8f8c31a1b93376
4
- data.tar.gz: 2a6ba790c9021d73593c657de850874ee30483b9defbe909be87b4cd5af44d1a
3
+ metadata.gz: 54ec8bba00d06538a146b978a969bc666870301ee49524fdfe565008fd49f059
4
+ data.tar.gz: ac3f9401adc1dfac45deda3a8532e6762d784f3933169f2cdd10857746f3ffa6
5
5
  SHA512:
6
- metadata.gz: 9e7c815ff399fce832806acd5e5e02af6f55c74de231390cbdf7f24cacc17eadf0c2608888e6e6a299c2eed96a3bb3c46ba0ad3a791509bb91bf732464e4194a
7
- data.tar.gz: 63ed1f73437dad7695725311b279c06b3dc57209d9a2211cfc305eafcacd7103ed110a933c7b3b524a5976b8eb55db24c6a256825a3c7c55adaccb76b2861e81
6
+ metadata.gz: 91bfb50504e0002561613a0a4b1cb87512011f12e2bd8c482ee6989d30d0bf970cc2dc87e0216ef830ffc9aec29feb55ec097801da389ce34aa81586ded6c4a8
7
+ data.tar.gz: 77ded5629a2fdcf12a47fa474a98ee681fe5e2c81ba25b8a33a9d86ed74c65a67ededa44d1a98efc601896d5bfd1abae82797b3a5012a8fe061a3e49a2ac4096
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cirro-ruby-client (2.5.11)
4
+ cirro-ruby-client (2.5.12)
5
5
  activesupport
6
6
  faraday (< 1.2.0)
7
7
  faraday_middleware
@@ -44,7 +44,7 @@ GEM
44
44
  rack (>= 0.2)
45
45
  jwt (2.7.0)
46
46
  method_source (1.0.0)
47
- minitest (5.17.0)
47
+ minitest (5.18.0)
48
48
  multipart-post (2.3.0)
49
49
  parallel (1.19.2)
50
50
  parser (2.7.2.0)
@@ -53,7 +53,7 @@ GEM
53
53
  coderay (~> 1.1)
54
54
  method_source (~> 1.0)
55
55
  public_suffix (4.0.6)
56
- rack (3.0.4.1)
56
+ rack (3.0.7)
57
57
  rainbow (3.0.0)
58
58
  rake (12.3.3)
59
59
  regexp_parser (1.8.1)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # CirroIO::Client
1
+ # CirroIOV2::Client
2
2
 
3
- This gem provides access to the [Cirro REST API](https://staging.cirro.io/api-docs/v1#cirro-api-documentation).
3
+ This gem provides access to the [Cirro REST API v2](https://cirroapiv2.docs.apiary.io).
4
4
 
5
5
  [![CircleCI](https://circleci.com/gh/test-IO/cirro-ruby-client/tree/master.svg?style=svg&circle-token=a77e4eac5646768d681283763d2a29a55a221d7c)](https://circleci.com/gh/test-IO/cirro-ruby-client/tree/master)
6
6
 
@@ -20,59 +20,6 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install cirro-ruby-client
22
22
 
23
-
24
- ## Configuration
25
-
26
- You need to create an initializer file in config/initializers.
27
-
28
- ```ruby
29
- CirroIO::Client.configure do |c|
30
- c.app_id 'WULnc6Y0rlaTBCSiHAb0kGWKFuIxPWBXJysyZeG3Rtw'
31
- c.private_key_path './storage/cirro.pem'
32
- c.site 'https://api.staging.cirro.io'
33
- end
34
- ```
35
-
36
-
37
- ## Development
38
-
39
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
-
41
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then wait for circle CI to complete, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
-
43
- ## License
44
-
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
- ```
58
-
59
- #### Creating Payouts for workers
60
-
61
- ```ruby
62
- app_worker = CirroIO::Client::AppWorker.load(id: 1234)
63
-
64
- CirroIO::Client::Payout.create(
65
- app_worker: app_worker,
66
- amount: 100, # € 1.00
67
- title: "Bonus for something",
68
- description: "Description of the bonus.",
69
- cost_center_key: "PROJECT-CODE",
70
- billing_date: DateTime.now
71
- )
72
- ```
73
-
74
- # CirroIOV2::Client
75
-
76
23
  ## Configuration
77
24
 
78
25
  ```ruby
@@ -99,26 +46,26 @@ user.worker
99
46
  # => { billable: false, document: {...} }
100
47
  ```
101
48
 
102
- ### Get notification preferences for a user
103
-
49
+ ### Create or update a worker document for a user
50
+ Will automatically create a worker account if not existing
104
51
  ```ruby
105
- preference = client.User.get_notification_preference(1)
106
- # => NotificationPreference object
52
+ user = client.User.worker(1, document: { foo: :bar })
53
+ # => User object
107
54
 
108
- preference.id
109
- # => '1'
55
+ user.worker.document
56
+ # => { foo: :bar }
57
+ ```
110
58
 
111
- preference.locale
112
- # => 'de'
59
+ ### Get notification preference of a user
113
60
 
114
- preference.topics
115
- # => Array of NotificationTopicPreference objects
61
+ ```ruby
62
+ client.User.notification_preference(1)
63
+ # => NotificationPreference object
116
64
  ```
117
-
118
- ### Update notification preferences for a user
65
+ ### Create or Update notification preferences for a user
119
66
 
120
67
  ```ruby
121
- client.User.update_notification_preference({
68
+ client.User.notification_preferences(1, {
122
69
  locale: 'de',
123
70
  topics: [
124
71
  { id: '1', preferences: { email: 'immediately' } },
@@ -165,11 +112,12 @@ client.Gig.create(
165
112
  url: "http://heathcote.co/zina.gibson",
166
113
  start_at: 1652285764,
167
114
  end_at: 1653412329,
168
- total_seats: 2,
115
+ seats_min: 2,
116
+ seats_max: 2,
169
117
  invitation_mode: "auto",
170
118
  filter_query: {
171
- status: "active",
172
- segment: "my_favorite_testers"
119
+ status: "active",
120
+ segment: "my_favorite_testers"
173
121
  },
174
122
  tasks: [
175
123
  { title: "Ah, Wilderness!", base_price: 300 }
@@ -186,9 +134,59 @@ client.Gig.create(
186
134
  # => Gig object
187
135
  ```
188
136
 
137
+ ### Update a gig
138
+ When your gig is already started, you can not update start_at anymore
139
+ ```ruby
140
+ gig_id = 1
141
+ client.Gig.update(gig_id,
142
+ title: "Favourite programming language?",
143
+ description: "Description of gig ...",
144
+ url: "http://heathcote.co/zina.gibson",
145
+ start_at: 1652285764,
146
+ end_at: 1653412329,
147
+ seats_min: 2,
148
+ seats_max: 2,
149
+ invitation_mode: "auto",
150
+ filter_query: {
151
+ status: "active",
152
+ segment: "my_favorite_testers"
153
+ },
154
+ notification_payload: {
155
+ project_title: "Corporate Tax",
156
+ task_title: "Add dataset",
157
+ task_type: "Review"
158
+ },
159
+ epam_options: {
160
+ extra_mile: true
161
+ }
162
+ )
163
+ # => Gig object
164
+ ```
165
+
166
+ ### Archive a gig
167
+
168
+ ```ruby
169
+ gig_id = 1
170
+
171
+ # archive now
172
+ client.Gig.archive(gig_id)
173
+
174
+ # archive later
175
+ client.Gig.archive(gig_id, archive_at: 1.day.from_now)
176
+ ```
177
+
178
+ ### Delete a gig
179
+
180
+ ```ruby
181
+ gig_id = 1
182
+
183
+ client.Gig.delete(gig_id)
184
+ ```
185
+
189
186
  ### Manually invite user to a gig
190
187
 
191
188
  ##### Invite single user
189
+
192
190
  ```ruby
193
191
  gig_id = 1
194
192
  app_user_id = 1
@@ -198,6 +196,7 @@ client.Gig.invite(gig_id, { user_id: app_user_id })
198
196
  ```
199
197
 
200
198
  ##### Invite multiple users and overwrite no_reward
199
+
201
200
  ```ruby
202
201
  gig_id = 1
203
202
  users = [{ id: 1, no_reward: true }, { id: 2, no_reward: true }]
@@ -206,6 +205,26 @@ client.Gig.invite(gig_id, { users: users })
206
205
  # => GigInvitationList object
207
206
  ```
208
207
 
208
+ ### GigTask
209
+ #### Add a new gig task to gig
210
+
211
+ ```ruby
212
+ gig_id = 1
213
+
214
+ client.Gig.tasks(gig_id, { title: "Critical Bug", base_price: 100 })
215
+ # => GigTask object
216
+ ```
217
+
218
+ #### Update a gig task
219
+
220
+ ```ruby
221
+ gig_id = 1
222
+ gig_task_id = 1
223
+
224
+ client.Gig.update_task(gig_id, gig_task_id, { base_price: 100 })
225
+ # => GigTask object
226
+ ```
227
+
209
228
  ## GigInvitation
210
229
  ### Get list of gig invitations
211
230
 
@@ -243,8 +262,143 @@ list.data
243
262
 
244
263
  ```ruby
245
264
  client.GigInvitation.accept(1)
265
+
266
+ # overwrite no_reward
267
+ client.GigInvitation.accept(1, no_reward: true)
268
+
269
+ ```
270
+
271
+ ### Reject a gig invitation
272
+
273
+ ```ruby
274
+ client.GigInvitation.reject(1)
275
+ ```
276
+
277
+ ### Expire a gig invitation
278
+
279
+ ```ruby
280
+ client.GigInvitation.expire(1)
281
+ ```
282
+
283
+ ### Reset an accepted or expired gig invitation
284
+
285
+ ```ruby
286
+ client.GigInvitation.reset(1)
287
+
288
+ # prevent reset notification
289
+ client.GigInvitation.reset(1, silent: true)
246
290
  ```
247
291
 
292
+ ## GigTimeActivity
293
+ ### List all gig time activities
294
+
295
+ ```ruby
296
+ list = client.GigTimeActivity.list
297
+ # => ListObject
298
+
299
+ list.has_more?
300
+ # => true
301
+
302
+ list.data
303
+ # => Array of GigTimeActivity objects
304
+
305
+ # filters
306
+ client.GigTimeActivity.list(gig_id: 1, user_id: 1)
307
+
308
+ # pagination
309
+ client.GigTimeActivity.list(limit: 100, after: 100)
310
+ ```
311
+
312
+ ### Create a gig time activity
313
+ You can't create gig time activity if the given user is not in your space or for the given user the gig invitation is set to no_reward
314
+
315
+ ```ruby
316
+ client.GigTimeActivity.create(
317
+ gig_id: 1,
318
+ user_id: 1,
319
+ date: "2023-04-10",
320
+ description: "Time Report for Space XYZ",
321
+ duration_in_ms: 1.hour.in_seconds * 1000 # make sure not to report > 8h per day
322
+ )
323
+ ```
324
+
325
+ ## GigResult
326
+ ### List all gig results
327
+
328
+ ```ruby
329
+ list = client.GigResult.list
330
+ # => ListObject
331
+
332
+ list.has_more?
333
+ # => true
334
+
335
+ list.data
336
+ # => Array of GigResult objects
337
+
338
+ # filters
339
+ client.GigResult.list(gig_id: 1, user_id: 1)
340
+
341
+ # pagination
342
+ client.GigResult.list(limit: 100, after: 100)
343
+ ```
344
+
345
+ ### Create a gig result
346
+ You can't create gig result if the given user is not in your space or for the given user the gig invitation is set to no_reward
347
+
348
+ ```ruby
349
+ client.GigResult.create(
350
+ gig_task_id: 1,
351
+ user_id: 1,
352
+ title: "Work for task1",
353
+ escription: "Good work for task1",
354
+ quantity: 2,
355
+ multiplier: 1.2,
356
+ delivery_date: "2023-04-10",
357
+ cost_center_key: "EPMTIO"
358
+ )
359
+ ```
360
+
361
+ ## BonusPayout
362
+ ### List all payouts
363
+
364
+ ```ruby
365
+ list = client.Payout.list
366
+ # => ListObject
367
+
368
+ list.has_more?
369
+ # => true
370
+
371
+ list.data
372
+ # => Array of Payout objects
373
+
374
+ # filters
375
+ client.Payout.list(reference_id: 1, reference_type: 'Gig', user_id: 1)
376
+
377
+ # pagination
378
+ client.Payout.list(limit: 100, after: 100)
379
+ ```
380
+
381
+ ### Create a bonus payout
382
+
383
+ ```ruby
384
+ client.Payout.create(
385
+ user_id: 1,
386
+ title: "Bonus Payment",
387
+ description: "Good work!",
388
+ amount: 1000,
389
+ billing_date: "2023-04-10",
390
+ cost_center_key: "EPMTIO"
391
+ )
392
+ ```
393
+
394
+ ### Delete a bonus payout
395
+ Only allowed for unbilled ones
396
+
397
+ ```ruby
398
+ client.Payout.delete(1)
399
+ ```
400
+
401
+ # Notifications
248
402
  ## Notification Locale
249
403
  ### Create a notification locale
250
404
 
@@ -293,6 +447,21 @@ client.NotificationConfiguration.list(limit: 100, after: 100) # pagination
293
447
  ```
294
448
 
295
449
  ## Notification Layout
450
+ ### List all notification layouts
451
+
452
+ ```ruby
453
+ list = client.NotificationLayout.list
454
+ # => ListObject
455
+
456
+ list.has_more?
457
+ # => true
458
+
459
+ list.data
460
+ # => Array of NotificationLayout objects
461
+
462
+ client.NotificationLayout.list(limit: 100, after: 100) # pagination
463
+ ```
464
+
296
465
  ### Create a notification layout
297
466
 
298
467
  ```ruby
@@ -380,6 +549,30 @@ client.NotificationTopic.create(
380
549
  )
381
550
  ```
382
551
 
552
+ ### Find a notification topic
553
+
554
+ ```ruby
555
+ client.NotificationTopic.find(1)
556
+ # => NotificationTopic object
557
+ ```
558
+
559
+ ### Update a notification topic
560
+
561
+ ```ruby
562
+ client.NotificationTopic.update(1, { name: "NewTopicName", preferences: { email: "daily" } })
563
+ # => NotificationTopic object
564
+ ```
565
+
566
+ ### Delete a notification topic
567
+
568
+ ```ruby
569
+ topic = client.NotificationTopic.delete(1)
570
+ # => NotificationTopicDelete object
571
+
572
+ topic.deleted
573
+ # => true
574
+ ```
575
+
383
576
  ## Notification (Topic) Template
384
577
  ### List all
385
578
 
@@ -416,8 +609,9 @@ client.NotificationTemplate.update(
416
609
  ### Delete a notification template
417
610
 
418
611
  ```ruby
419
- client.NotificationTemplate.delete('1')
612
+ client.NotificationTemplate.delete(1)
420
613
  ```
614
+
421
615
  ## Notifcation Topic Preference
422
616
  ### List all
423
617
 
@@ -456,3 +650,56 @@ client.NotificationBroadcast.create(
456
650
  notification_topic_id: 1
457
651
  )
458
652
  ```
653
+
654
+ # CirroIO::Client (DEPRECATED)
655
+
656
+ ## Configuration
657
+
658
+ You need to create an initializer file in config/initializers.
659
+
660
+ ```ruby
661
+ CirroIO::Client.configure do |c|
662
+ c.app_id 'WULnc6Y0rlaTBCSiHAb0kGWKFuIxPWBXJysyZeG3Rtw'
663
+ c.private_key_path './storage/cirro.pem'
664
+ c.site 'https://api.staging.cirro.io'
665
+ end
666
+ ```
667
+
668
+
669
+
670
+ ## Usage
671
+
672
+ #### Bulk create gig invitations
673
+
674
+ ```ruby
675
+ gig = CirroIO::Client::Gig.load(id: 1)
676
+ filter = CirroIO::Client::WorkerFilter.new(filter_query: '{ "app_worker_id": { "$in": [1,2,3] } }')
677
+ invitation = CirroIO::Client::GigInvitation.new(gig: gig)
678
+
679
+ invitation.bulk_create_with(filter, auto_accept: true) # by default auto_accept is false
680
+ ```
681
+
682
+ #### Creating Payouts for workers
683
+
684
+ ```ruby
685
+ app_worker = CirroIO::Client::AppWorker.load(id: 1234)
686
+
687
+ CirroIO::Client::Payout.create(
688
+ app_worker: app_worker,
689
+ amount: 100, # € 1.00
690
+ title: "Bonus for something",
691
+ description: "Description of the bonus.",
692
+ cost_center_key: "PROJECT-CODE",
693
+ billing_date: DateTime.now
694
+ )
695
+ ```
696
+
697
+ # Development
698
+
699
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
700
+
701
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then wait for circle CI to complete, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
702
+
703
+ # License
704
+
705
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,7 +1,7 @@
1
1
  # rubocop:disable Style/MutableConstant
2
2
  module CirroIO
3
3
  module Client
4
- VERSION = '2.5.11'
4
+ VERSION = '2.5.12'
5
5
  end
6
6
  end
7
7
  # rubocop:enable Style/MutableConstant
@@ -24,6 +24,11 @@ module CirroIOV2
24
24
  response = client.request_client.request(:post, resource_root, body: params)
25
25
  Responses::NotificationTopicResponse.new(response.body)
26
26
  end
27
+
28
+ def delete(id)
29
+ response = client.request_client.request(:delete, "#{resource_root}/#{id}")
30
+ Responses::NotificationTopicDeleteResponse.new(response.body)
31
+ end
27
32
  end
28
33
  end
29
34
  end
@@ -10,6 +10,11 @@ module CirroIOV2
10
10
  response = client.request_client.request(:post, resource_root, body: params)
11
11
  Responses::PayoutResponse.new(response.body)
12
12
  end
13
+
14
+ def delete(id)
15
+ response = client.request_client.request(:delete, "#{resource_root}/#{id}")
16
+ Responses::PayoutDeleteResponse.new(response.body)
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -11,6 +11,11 @@ module CirroIOV2
11
11
  CirroIOV2::Responses::UserResponse.new(response.body)
12
12
  end
13
13
 
14
+ def notification_preference(id)
15
+ response = client.request_client.request(:get, "#{resource_root}/#{id}/notification_preference")
16
+ CirroIOV2::Responses::UserNotificationPreferenceResponse.new(response.body)
17
+ end
18
+
14
19
  def notification_preferences(id, params)
15
20
  response = client.request_client.request(:post, "#{resource_root}/#{id}/notification_preferences", body: params)
16
21
  CirroIOV2::Responses::UserNotificationPreferenceResponse.new(response.body)
@@ -15,6 +15,14 @@ module CirroIOV2
15
15
  :NotificationTemplateListResponse,
16
16
  ].freeze
17
17
 
18
+ DELETE_RESPONSES = [
19
+ :GigDeleteResponse,
20
+ :PayoutDeleteResponse,
21
+ :NotificationTemplateDeleteResponse,
22
+ :NotificationLayoutTemplateDeleteResponse,
23
+ :NotificationTopicDeleteResponse,
24
+ ].freeze
25
+
18
26
  UserResponse = Struct.new(:id, :object, :first_name, :last_name, :time_zone, :birthday, :country_code, :epam, :worker, :anonymous_email) do
19
27
  include Base
20
28
  end
@@ -48,15 +56,11 @@ module CirroIOV2
48
56
  include Base
49
57
  end
50
58
 
51
- GigDeleteResponse = Struct.new(:id, :object, :deleted) do
52
- include Base
53
- end
54
-
55
59
  GigTaskResponse = Struct.new(:id, :object, :title, :base_price) do
56
60
  include Base
57
61
  end
58
62
 
59
- GigInvitationResponse = Struct.new(:id, :object, :status, :gig_id, :user_id, :no_reward) do
63
+ GigInvitationResponse = Struct.new(:id, :object, :status, :gig_id, :user_id, :no_reward, :epam_bench_status) do
60
64
  include Base
61
65
  end
62
66
 
@@ -114,10 +118,6 @@ module CirroIOV2
114
118
  include Base
115
119
  end
116
120
 
117
- NotificationLayoutTemplateDeleteResponse = Struct.new(:id, :object, :deleted) do
118
- include Base
119
- end
120
-
121
121
  NotificationTopicResponse = Struct.new(:id, :object, :name, :notification_layout_id, :preferences, :templates) do
122
122
  self::NESTED_RESPONSES = { templates: :NotificationTemplateListResponse }.freeze
123
123
  include Base
@@ -127,10 +127,6 @@ module CirroIOV2
127
127
  include Base
128
128
  end
129
129
 
130
- NotificationTemplateDeleteResponse = Struct.new(:id, :object, :deleted) do
131
- include Base
132
- end
133
-
134
130
  NotificationBroadcastResponse = Struct.new(:id, :object, :payload, :recipients, :notification_topic_id) do
135
131
  include Base
136
132
  end
@@ -139,12 +135,17 @@ module CirroIOV2
139
135
  include Base
140
136
  end
141
137
 
142
- # cover the list responses
138
+ # cover the list and delete responses
143
139
  def self.const_missing(name)
144
140
  return const_get(name) if const_defined? name
145
- return unless LIST_RESPONSES.include? name
146
141
 
147
- klass = Class.new(Struct.new(:object, :url, :has_more, :data)) { include Base }
142
+ struct = nil
143
+ struct = Struct.new(:object, :url, :has_more, :data) if LIST_RESPONSES.include?(name)
144
+ struct = Struct.new(:id, :object, :deleted) if DELETE_RESPONSES.include?(name)
145
+
146
+ return unless struct.present?
147
+
148
+ klass = Class.new(struct) { include Base }
148
149
  const_set(name, klass)
149
150
  end
150
151
  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: 2.5.11
4
+ version: 2.5.12
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: 2023-02-27 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport