Class: Tazworks::Client

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

Overview

Tazworks Clients Model

Instance Attribute Summary

Attributes inherited from Model

#attributes, #attributes_loaded, #ids

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#attributes_loaded?, #clientGuid, find, #initialize, initialize_from_response, #load_attributes, #loaded_attributes, #reload

Constructor Details

This class inherits a constructor from Tazworks::Model

Class Method Details

.all(params = {}) ⇒ Object

docs.developer.tazworks.com/#e008c159-b8d7-4843-a08f-ff483315a067 tazapi defaults to params { page: 0, size: 30 }



14
15
16
17
# File 'lib/tazworks/client.rb', line 14

def self.all(params = {})
  raw_response = RestClient.get('/v1/clients', { params: })
  ClientPagedResponse.new(raw_response, {})
end

.ancestors(_clientGuid) ⇒ Object



25
26
27
# File 'lib/tazworks/client.rb', line 25

def self.ancestors(_clientGuid)
  raise 'Unimplemented'
end

.descendents(_clientGuid) ⇒ Object



20
21
22
# File 'lib/tazworks/client.rb', line 20

def self.descendents(_clientGuid)
  raise 'Unimplemented'
end

.get(ids) ⇒ Object

docs.developer.tazworks.com/#3a09caba-349b-4969-a55a-1cbcaea0136c TODO: WARNING - UNTESTED - maintainer doesn’t have a proper token for this endpoint!



8
9
10
# File 'lib/tazworks/client.rb', line 8

def self.get(ids)
  RestClient.get("/v1/clients/#{ids[:clientGuid]}")
end

Instance Method Details

#ancestorsObject



58
59
60
# File 'lib/tazworks/client.rb', line 58

def ancestors
  Client.ancestors(clientGuid)
end

#applicants(params = {}) ⇒ Object

Orders/Applicants



33
34
35
# File 'lib/tazworks/client.rb', line 33

def applicants(params = {})
  Applicant.all(clientGuid, params)
end

#client_products(params = {}) ⇒ Object



41
42
43
# File 'lib/tazworks/client.rb', line 41

def client_products(params = {})
  ClientProduct.all(clientGuid, params)
end

#create_applicant(params) ⇒ Object



45
46
47
# File 'lib/tazworks/client.rb', line 45

def create_applicant(params)
  Tazworks::Applicant.create(clientGuid, params)
end

#descendents(clientGuid) ⇒ Object



62
63
64
# File 'lib/tazworks/client.rb', line 62

def descendents(clientGuid)
  Client.descendents(clientGuid)
end

#find_applicant(applicantGuid) ⇒ Object



50
51
52
# File 'lib/tazworks/client.rb', line 50

def find_applicant(applicantGuid)
  Tazworks::Applicant.find(ids: { clientGuid:, applicantGuid: })
end

#orders(params = {}) ⇒ Object



37
38
39
# File 'lib/tazworks/client.rb', line 37

def orders(params = {})
  Order.all(clientGuid, params)
end

#submit_order(params) ⇒ Object



54
55
56
# File 'lib/tazworks/client.rb', line 54

def submit_order(params)
  Order.create(clientGuid, params)
end