Added Bidsketch::Fee

Dylan Montgomery committed Jun 03, 2015
commit a108a8e30505379facb6b4954333d4ca03e4410b
Showing 3 changed files with 49 additions and 0 deletions
bidsketch.rb b/lib/bidsketch.rb +1 -0
@@ @@ -2,6 +2,7 @@ require "bidsketch/version"
require "bidsketch/api"
require "bidsketch/bidsketch_object"
require "bidsketch/client"
+ require "bidsketch/fee"
module Bidsketch
class << self
bidsketch/fee.rb b/lib/bidsketch/fee.rb +16 -0
@@ @@ -0,0 +1,16 @@
+ module Bidsketch
+ class Fee < BidsketchObject
+ class << self
+ def all
+ Bidsketch::API.get('/fees.json').map { |fee| self.new(fee) }
+ end
+
+ def find(id)
+ response = Bidsketch::API.get("/fees/#{id}.json")
+ if response
+ self.new(response)
+ end
+ end
+ end
+ end
+ end
\ No newline at end of file
spec/fee_spec.rb +32 -0
@@ @@ -0,0 +1,32 @@
+ describe Bidsketch::Fee do
+ describe '#all' do
+ it 'returns all clients', vcr: true do
+ fees = Bidsketch::Fee.all
+ fee = fees.first
+ attributes = [
+ :id, :name, :url, :app_url, :created_at, :updated_at,
+ :category, :total, :feetype, :details
+ ]
+
+ attributes.each do |attribute|
+ expect(fee.respond_to?(attribute)).to be true
+ end
+ end
+ end
+
+ describe '#find' do
+ let(:fee_id) { 180219 }
+ it 'returns a client', vcr: true do
+ fee = Bidsketch::Fee.find(fee_id)
+ attributes = [
+ :id, :name, :url, :app_url, :created_at, :updated_at,
+ :quantity, :category, :total, :currency, :amount, :unit,
+ :details, :feetype, :description
+ ]
+
+ attributes.each do |attribute|
+ expect(fee.respond_to?(attribute)).to be true
+ end
+ end
+ end
+ end