Class: Makeleaps::Request::URLManager

Inherits:
Object
  • Object
show all
Defined in:
lib/makeleaps/request/url_manager.rb

Constant Summary collapse

API_ENDPOINT_BASE =
'https://api.makeleaps.com/api'
GENERIC_ENDPOINT =
"#{API_ENDPOINT_BASE}/partner"
CURRENCY_ENDPOINT =
"#{API_ENDPOINT_BASE}/currency"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#partner_midObject (readonly)

Returns the value of attribute partner_mid.



8
9
10
# File 'lib/makeleaps/request/url_manager.rb', line 8

def partner_mid
  @partner_mid
end

Instance Method Details

#build_url_for(resource_or_url, mid = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/makeleaps/request/url_manager.rb', line 14

def build_url_for(resource_or_url, mid=nil)
  case resource_or_url
  when String
    resource_or_url # assume its a url
  when :partner
    compose_url GENERIC_ENDPOINT, mid
  when :currency
    compose_url CURRENCY_ENDPOINT
  when :client_contact
    # TODO: ensure that @partner_mid exists
    compose_url GENERIC_ENDPOINT, @partner_mid, :client, mid, :contact
  else
    # TODO: ensure that @partner_mid exists
    compose_url GENERIC_ENDPOINT, @partner_mid, resource_or_url, mid
  end
end

#set_partner!(partner_mid) ⇒ Object



10
11
12
# File 'lib/makeleaps/request/url_manager.rb', line 10

def set_partner!(partner_mid)
  @partner_mid = partner_mid
end