Class: Octobat::BalanceTransaction

Inherits:
APIResource show all
Extended by:
APIOperations::List
Defined in:
lib/octobat/balance_transaction.rb

Instance Attribute Summary

Attributes inherited from OctobatObject

#api_key, #parent_obj

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::List

list, set_parent_resource

Methods inherited from APIResource

class_name, #refresh, retrieve

Methods inherited from OctobatObject

#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Octobat::OctobatObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Octobat::OctobatObject

Class Method Details

.set_parent_resource(filters) ⇒ Object



23
24
25
# File 'lib/octobat/balance_transaction.rb', line 23

def self.set_parent_resource(filters)
  @parent_resource = filters.select{|k, v| [:payout].include?(k)}
end

.urlObject



17
18
19
20
21
# File 'lib/octobat/balance_transaction.rb', line 17

def self.url
  if @parent_resource.include?(:payout)
    "#{Payout.url}/#{CGI.escape(@parent_resource[:payout])}/balance_transactions"
  end
end

Instance Method Details

#parentize_urlObject



9
10
11
12
13
14
15
# File 'lib/octobat/balance_transaction.rb', line 9

def parentize_url
  if parent_obj.include?(:payout)
    "#{Payout.url}/#{CGI.escape(parent_obj[:payout])}/balance_transactions/#{CGI.escape(id)}"
  else
    url
  end
end

#urlObject



5
6
7
# File 'lib/octobat/balance_transaction.rb', line 5

def url
  !parent_obj.nil? ? parentize_url : super
end