class V2Intuity::Endpoints::Endpoint

Constants

ENDPOINTS

Attributes

base_uri[RW]
endpoint[RW]
id[RW]
org_id[RW]
path[RW]
token[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/v2_intuity/endpoints/endpoint.rb, line 11
def initialize(options = {})
  @endpoint = options[:endpoint]
  @path = options.fetch(:path, 'organizations')
  @id = options[:id]
  add_constants(options)
end

Public Instance Methods

sign_with() click to toggle source
# File lib/v2_intuity/endpoints/endpoint.rb, line 36
def sign_with
  [:access_token]
end
uri(options = {}) click to toggle source
# File lib/v2_intuity/endpoints/endpoint.rb, line 18
def uri(options = {})
  uri_options(options)
  if @id.nil?
    "#{@base_uri}/#{@path}/#{@org_id}/#{@endpoint}"
  else
    "#{@base_uri}/#{@path}/#{@org_id}/users/#{@id}/#{@endpoint}"
  end
end
uri_options(options = {}) click to toggle source
# File lib/v2_intuity/endpoints/endpoint.rb, line 27
def uri_options(options = {})
  @base_uri ||= options[:base_uri]
  @org_id ||= options[:org_id]
  @id ||= options[:id]

  raise 'org_id is needed' unless @org_id
  raise 'base_uri is needed' unless @base_uri
end

Private Instance Methods

add_constants(options = {}) click to toggle source
# File lib/v2_intuity/endpoints/endpoint.rb, line 42
def add_constants(options = {})
  @base_uri  = options[:base_uri]
  @token     = options[:token]
  @org_id    = options[:org_id]
end