Skip to content

Commit 1ed603f

Browse files
authored
Merge pull request #15 from test-IO/feature/add_reward
Feature/add reward
2 parents 2c3c338 + 01d080b commit 1ed603f

File tree

7 files changed

+92
-7
lines changed

7 files changed

+92
-7
lines changed

Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cirro-ruby-client (1.4.0)
4+
cirro-ruby-client (1.5.0)
55
faraday (< 1.2.0)
66
faraday_middleware
77
json_api_client (>= 1.10.0)
@@ -10,9 +10,9 @@ PATH
1010
GEM
1111
remote: https://rubygems.org/
1212
specs:
13-
activemodel (6.1.1)
14-
activesupport (= 6.1.1)
15-
activesupport (6.1.1)
13+
activemodel (6.1.3.2)
14+
activesupport (= 6.1.3.2)
15+
activesupport (6.1.3.2)
1616
concurrent-ruby (~> 1.0, >= 1.0.2)
1717
i18n (>= 1.6, < 2)
1818
minitest (>= 5.1)
@@ -42,9 +42,9 @@ GEM
4242
faraday (>= 0.15.2, < 1.2.0)
4343
faraday_middleware (>= 0.9.0, < 1.2.0)
4444
rack (>= 0.2)
45-
jwt (2.2.2)
45+
jwt (2.2.3)
4646
method_source (1.0.0)
47-
minitest (5.14.3)
47+
minitest (5.14.4)
4848
multipart-post (2.1.1)
4949
parallel (1.19.2)
5050
parser (2.7.2.0)

lib/cirro_io/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
require 'cirro_io/client/gig_result'
1515
require 'cirro_io/client/gig_time_activity'
1616
require 'cirro_io/client/gig'
17+
require 'cirro_io/client/payout'
1718

1819
module CirroIO
1920
module Client

lib/cirro_io/client/app_worker.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module Client
33
class AppWorker < Base
44
has_one :app_user
55
has_many :gig_invitations
6+
has_many :payouts
67
end
78
end
89
end

lib/cirro_io/client/payout.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/cirro_io/client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rubocop:disable Style/MutableConstant
22
module CirroIO
33
module Client
4-
VERSION = '1.4.0'
4+
VERSION = '1.5.0'
55
end
66
end
77
# rubocop:enable Style/MutableConstant
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
RSpec.describe CirroIO::Client::Payout do
2+
let(:app_worker) { CirroIO::Client::AppWorker.load id: 1 }
3+
let :response_headers do
4+
{
5+
'Content-Type' => 'application/json',
6+
}
7+
end
8+
9+
before do
10+
configure_api_client
11+
end
12+
13+
describe '.create' do
14+
let(:request_url) { "#{test_site}/v1/payouts" }
15+
let(:payout) { described_class.create app_worker: app_worker, **attributes }
16+
let(:attributes) do
17+
{
18+
title: Faker::Hipster.sentence,
19+
description: Faker::Hipster.paragraph,
20+
'billing-date': Date.today.to_s,
21+
amount: 100,
22+
}
23+
end
24+
25+
before do
26+
stub_request(:post, request_url).to_return(body: File.read('./spec/fixtures/payout.json'), headers: response_headers)
27+
end
28+
29+
it 'creates a payout for the app worker' do
30+
request_body = {
31+
data: {
32+
type: 'payouts',
33+
relationships: {
34+
'app-worker': {
35+
data: {
36+
type: 'app-workers',
37+
id: 1,
38+
},
39+
},
40+
},
41+
attributes: attributes,
42+
},
43+
}
44+
45+
expect(payout).to be_persisted
46+
expect(a_request(:post, request_url).with(body: request_body.to_json)).to have_been_made
47+
end
48+
end
49+
end

spec/fixtures/payout.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"data": {
3+
"id": "1",
4+
"type": "payouts",
5+
"attributes": {
6+
"amount": 8969,
7+
"title": "The Soldier's Art",
8+
"description": "Something",
9+
"billing-date": "2021-06-25",
10+
"external-customer-id": null
11+
},
12+
"relationships": {
13+
"app-worker": {
14+
"data": {
15+
"type": "app-workers",
16+
"id": "52"
17+
}
18+
},
19+
"reference": {
20+
"data": {
21+
"type": "gigs",
22+
"id": "40"
23+
}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)