Module: Place

Defined in:
lib/place.rb,
lib/place/client.rb,
lib/place/version.rb,
lib/place/resources.rb,
lib/place/exceptions.rb,
lib/place/api_resource.rb

Defined Under Namespace

Classes: APIException, APIResource, AccessToken, Account, Address, AutopayEnrollment, Client, DepositAccount, Event, Forbidden, InternalError, InvalidArguments, InvalidRequest, InvalidResponse, Invoice, InvoiceItem, InvoiceItemAllocation, InvoicePayer, MethodNotAllowed, NotFound, PaymentMethod, RecurringInvoice, TooManyRequests, Transaction, TransactionAllocation, Unauthorized

Constant Summary collapse

VERSION =
'0.5.5'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



18
19
20
# File 'lib/place.rb', line 18

def api_key
  @api_key
end

.api_urlObject

Returns the value of attribute api_url.



18
19
20
# File 'lib/place.rb', line 18

def api_url
  @api_url
end

.default_clientObject

Returns the value of attribute default_client.



18
19
20
# File 'lib/place.rb', line 18

def default_client
  @default_client
end

.PROD_URLObject

Returns the value of attribute PROD_URL.



18
19
20
# File 'lib/place.rb', line 18

def PROD_URL
  @PROD_URL
end

.TEST_URLObject

Returns the value of attribute TEST_URL.



18
19
20
# File 'lib/place.rb', line 18

def TEST_URL
  @TEST_URL
end

Class Method Details

.conv_object(obj, client: nil, inverse: false) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/place/api_resource.rb', line 17

def self.conv_object(obj, client: nil, inverse: false)
  obj = obj.clone
  if obj.class == Array
    iter = obj.map.with_index{|a,i| [i,a] }
  else
    iter = obj
  end

  iter.each do |key, val|
    if inverse
      if val.is_a?(Place::APIResource)
        obj[key] = val._obj
        val = obj[key]
      end
    elsif val.is_a?(Hash) and val['object']
      for resource in Place::APIResource.descendants
        if val['object'] != resource.object_type
          next
        end

        obj[key] = resource.new(client: client, obj: val)
        val = obj[key]
        break
      end
    end
    if [Hash, Array].member? val.class
      obj[key] = Place::conv_object(val, client:client, inverse: inverse)
    end
  end

  return obj
end

.merge_obj(obj: nil, **params) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/place/api_resource.rb', line 7

def self.merge_obj( obj: nil, **params )
  params = params.collect{|k,v| [k.to_s, v]}.to_h
  if obj
    obj = obj.merge(params)
  else
    obj = params
  end
  return obj
end