cirro-ruby-client 0.1.2 → 1.2.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: 90ef4e3b2eec3a5746f2592a6c201860d475ecc821206b699dafdd8a6ac12cd5
4
- data.tar.gz: 5d4ecb0ea0c6e2a59505b46ac765e44e57a5e508ea3f355d7748887bd3ea1262
3
+ metadata.gz: 4345f8d02b4f3afcc21cd23b3b0c2edcfadeeeeb887dd0e7c7f501b5bb2ced40
4
+ data.tar.gz: 00ee7217ad02c180d22cae50b5c23a915a8998c47efacf68e99c7da630e4d255
5
5
  SHA512:
6
- metadata.gz: a4d3bff833b2204df8a8c6af7b54e6b61cdd849262aea8dac29870b22d397ad8915aeb50c36b7e186bec433f5aa68999bec673a8071d9f930d785a5a960e40d8
7
- data.tar.gz: 7bbef31c78ba734ac45adccd83b0d7785aedc6f09d405b8e7e2850398bfc4951caeef07ae64c02d66d596b11421cb4a30f2e85f732f7ba5db872a8f4534833e0
6
+ metadata.gz: ec030038393796f3dcac6ccc457453100584e8fc2aeb4d2f9016a2b3d2cd004078e6155062bd940584909659f1e026cd325b0c2702dd7936afe80d03f7b7580e
7
+ data.tar.gz: '0853aff5207749a568f87fce5bf43d87ab47d883513c1c389f15d10398f71ce7d8f5ca4fced3e7f49aec4b042b74a34ccd2573a73d3c9fd2234c4de11fec3e0c'
@@ -64,3 +64,7 @@ workflows:
64
64
  - deploy:
65
65
  requires:
66
66
  - build
67
+ filters:
68
+ branches:
69
+ only:
70
+ - master
data/Gemfile CHANGED
@@ -5,8 +5,11 @@ gemspec
5
5
 
6
6
  gem 'rake', '~> 12.0'
7
7
  gem 'rspec', '~> 3.0'
8
+ # tempprary till my PR gets approved in original gem
9
+ gem 'json_api_client', git: 'https://github.com/inderps/json_api_client'
8
10
 
9
11
  group :development do
12
+ gem 'faker'
10
13
  gem 'pry'
11
14
  gem 'rubocop', require: false
12
15
  gem 'rubocop-rspec'
@@ -1,16 +1,28 @@
1
+ GIT
2
+ remote: https://github.com/inderps/json_api_client
3
+ revision: 675e1c8b1bf9978ca4722c2aa19314fb0aa5860b
4
+ specs:
5
+ json_api_client (1.17.1)
6
+ activemodel (>= 3.2.0)
7
+ activesupport (>= 3.2.0)
8
+ addressable (~> 2.2)
9
+ faraday (>= 0.15.2, < 1.2.0)
10
+ faraday_middleware (>= 0.9.0, < 1.2.0)
11
+ rack (>= 0.2)
12
+
1
13
  PATH
2
14
  remote: .
3
15
  specs:
4
- cirro-ruby-client (0.1.2)
5
- json_api_client
16
+ cirro-ruby-client (1.1.0)
17
+ faraday_middleware
6
18
  jwt
7
19
 
8
20
  GEM
9
21
  remote: https://rubygems.org/
10
22
  specs:
11
- activemodel (6.0.3.3)
12
- activesupport (= 6.0.3.3)
13
- activesupport (6.0.3.3)
23
+ activemodel (6.0.3.4)
24
+ activesupport (= 6.0.3.4)
25
+ activesupport (6.0.3.4)
14
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
27
  i18n (>= 0.7, < 2)
16
28
  minitest (~> 5.1)
@@ -23,6 +35,8 @@ GEM
23
35
  concurrent-ruby (1.1.7)
24
36
  crack (0.4.4)
25
37
  diff-lcs (1.4.4)
38
+ faker (2.14.0)
39
+ i18n (>= 1.6, < 2)
26
40
  faraday (1.0.1)
27
41
  multipart-post (>= 1.2, < 3)
28
42
  faraday_middleware (1.0.0)
@@ -30,13 +44,6 @@ GEM
30
44
  hashdiff (1.0.1)
31
45
  i18n (1.8.5)
32
46
  concurrent-ruby (~> 1.0)
33
- json_api_client (1.17.1)
34
- activemodel (>= 3.2.0)
35
- activesupport (>= 3.2.0)
36
- addressable (~> 2.2)
37
- faraday (>= 0.15.2, < 1.2.0)
38
- faraday_middleware (>= 0.9.0, < 1.2.0)
39
- rack (>= 0.2)
40
47
  jwt (2.2.2)
41
48
  method_source (1.0.0)
42
49
  minitest (5.14.2)
@@ -81,20 +88,22 @@ GEM
81
88
  rubocop (~> 0.87)
82
89
  ruby-progressbar (1.10.1)
83
90
  thread_safe (0.3.6)
84
- tzinfo (1.2.7)
91
+ tzinfo (1.2.8)
85
92
  thread_safe (~> 0.1)
86
93
  unicode-display_width (1.7.0)
87
94
  webmock (3.9.1)
88
95
  addressable (>= 2.3.6)
89
96
  crack (>= 0.3.2)
90
97
  hashdiff (>= 0.4.0, < 2.0.0)
91
- zeitwerk (2.4.0)
98
+ zeitwerk (2.4.2)
92
99
 
93
100
  PLATFORMS
94
101
  ruby
95
102
 
96
103
  DEPENDENCIES
97
104
  cirro-ruby-client!
105
+ faker
106
+ json_api_client!
98
107
  pry
99
108
  rake (~> 12.0)
100
109
  rspec (~> 3.0)
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem provides access to the [Cirro REST API](https://staging.cirro.io/api-docs/v1#cirro-api-documentation).
4
4
 
5
+ [![CircleCI](https://circleci.com/gh/test-IO/cirro-ruby-client/tree/master.svg?style=svg)](https://circleci.com/gh/test-IO/cirro-ruby-client/tree/master)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -26,5 +26,5 @@ 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 'json_api_client'
29
+ spec.add_runtime_dependency 'faraday_middleware'
30
30
  end
@@ -4,7 +4,14 @@ require 'cirro_io/client/configuration'
4
4
  require 'cirro_io/client/response_debugging_middleware'
5
5
  require 'cirro_io/client/jwt_authentication'
6
6
  require 'cirro_io/client/base'
7
+ require 'cirro_io/client/gig_invitation'
8
+ require 'cirro_io/client/app_user'
7
9
  require 'cirro_io/client/app_worker'
10
+ require 'cirro_io/client/worker_invitation_filter'
11
+ require 'cirro_io/client/gig_task'
12
+ require 'cirro_io/client/gig_result'
13
+ require 'cirro_io/client/gig_time_activity'
14
+ require 'cirro_io/client/gig'
8
15
 
9
16
  module CirroIO
10
17
  module Client
@@ -0,0 +1,6 @@
1
+ module CirroIO
2
+ module Client
3
+ class AppUser < Base
4
+ end
5
+ end
6
+ end
@@ -1,9 +1,8 @@
1
1
  module CirroIO
2
2
  module Client
3
3
  class AppWorker < Base
4
- def self.resource_name
5
- 'app-workers'
6
- end
4
+ has_one :app_user
5
+ has_many :gig_invitations
7
6
  end
8
7
  end
9
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 = '0.1.2'
4
+ VERSION = '1.2.0'
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: 0.1.2
4
+ version: 1.2.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-10-08 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json_api_client
28
+ name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -61,12 +61,19 @@ files:
61
61
  - bin/setup
62
62
  - cirro-ruby-client.gemspec
63
63
  - lib/cirro_io/client.rb
64
+ - lib/cirro_io/client/app_user.rb
64
65
  - lib/cirro_io/client/app_worker.rb
65
66
  - lib/cirro_io/client/base.rb
66
67
  - lib/cirro_io/client/configuration.rb
68
+ - lib/cirro_io/client/gig.rb
69
+ - lib/cirro_io/client/gig_invitation.rb
70
+ - lib/cirro_io/client/gig_result.rb
71
+ - lib/cirro_io/client/gig_task.rb
72
+ - lib/cirro_io/client/gig_time_activity.rb
67
73
  - lib/cirro_io/client/jwt_authentication.rb
68
74
  - lib/cirro_io/client/response_debugging_middleware.rb
69
75
  - lib/cirro_io/client/version.rb
76
+ - lib/cirro_io/client/worker_invitation_filter.rb
70
77
  homepage: https://cirro.io/api-docs/v1#cirro-api-documentation
71
78
  licenses:
72
79
  - MIT