Class: Exact::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/exact/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, division:, service:, endpoint:) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
# File 'lib/exact/client.rb', line 8

def initialize(access_token:, division:, service:, endpoint:)
  @access_token = access_token
  @division     = division
  @service      = service
  @endpoint     = endpoint
  @exact_url    = "#{Exact.configuration.exact_url}/#{division}/#{service}"
  @exact_client = OData::Service.new(@exact_url, access_token: access_token, namespace: 'Exactonline')
  @exact_client.send(endpoint)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mthd, *args, &block) ⇒ Object



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

def method_missing(mthd, *args, &block)
  exact_client.send(mthd, *args, &block) if exact_client.respond_to? mthd.to_s
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



6
7
8
# File 'lib/exact/client.rb', line 6

def access_token
  @access_token
end

#divisionObject

Returns the value of attribute division.



6
7
8
# File 'lib/exact/client.rb', line 6

def division
  @division
end

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/exact/client.rb', line 6

def endpoint
  @endpoint
end

#exact_clientObject (readonly)

Returns the value of attribute exact_client.



5
6
7
# File 'lib/exact/client.rb', line 5

def exact_client
  @exact_client
end

#exact_urlObject (readonly)

Returns the value of attribute exact_url.



5
6
7
# File 'lib/exact/client.rb', line 5

def exact_url
  @exact_url
end

#serviceObject

Returns the value of attribute service.



6
7
8
# File 'lib/exact/client.rb', line 6

def service
  @service
end