Skip to content

Commit

Permalink
Add amount to Reward object.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppostma committed Aug 30, 2024
1 parent 7f0759c commit 63915ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/kentaa/api/resources/reward.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'bigdecimal'

module Kentaa
module Api
module Resources
Expand All @@ -18,6 +20,10 @@ def type
data[:type]
end

def amount
BigDecimal(data[:amount])
end

def title
data[:title]
end
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/responses/donation.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"reward": {
"id": 1,
"type": "SiteReward",
"amount": "10.0",
"title": "Awesome reward",
"description": "Lorem ipsum",
"ask_for_address": true
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/responses/donations.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"reward": {
"id": 1,
"type": "SiteReward",
"amount": "10.0",
"title": "Awesome reward",
"description": "Lorem ipsum",
"ask_for_address": true
Expand Down
1 change: 1 addition & 0 deletions spec/kentaa/api/resources/donation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
it 'returns the associated reward' do
expect(response.reward).to be_a(Kentaa::Api::Resources::Reward)
expect(response.reward.type).to eq('SiteReward')
expect(response.reward.amount).to eq(10)
expect(response.reward.title).to eq('Awesome reward')
expect(response.reward.description).to eq('Lorem ipsum')
expect(response.reward.ask_for_address?).to be true
Expand Down

0 comments on commit 63915ca

Please sign in to comment.