Class: HaloMspApi::Client

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

Overview

Client class for Halo MSP API rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = nil) ⇒ Client

Returns a new instance of Client.

Raises:



13
14
15
16
17
18
19
20
# File 'lib/halo_msp_api/client.rb', line 13

def initialize(configuration = nil)
  @configuration = configuration || HaloMspApi.configuration
  raise ConfigurationError, 'Configuration is required' unless @configuration&.valid?

  @connection = build_connection
  @access_token = nil
  @token_expires_at = nil
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



11
12
13
# File 'lib/halo_msp_api/client.rb', line 11

def configuration
  @configuration
end

#connectionObject (readonly)

Returns the value of attribute connection.



11
12
13
# File 'lib/halo_msp_api/client.rb', line 11

def connection
  @connection
end

Instance Method Details

#actionsObject

Resource accessors



23
24
25
# File 'lib/halo_msp_api/client.rb', line 23

def actions
  @actions ||= Resources::Actions.new(self)
end

#agentsObject



27
28
29
# File 'lib/halo_msp_api/client.rb', line 27

def agents
  @agents ||= Resources::Agents.new(self)
end

#appointmentsObject



31
32
33
# File 'lib/halo_msp_api/client.rb', line 31

def appointments
  @appointments ||= Resources::Appointments.new(self)
end

#assetsObject



35
36
37
# File 'lib/halo_msp_api/client.rb', line 35

def assets
  @assets ||= Resources::Assets.new(self)
end

#clientsObject



39
40
41
# File 'lib/halo_msp_api/client.rb', line 39

def clients
  @clients ||= Resources::Clients.new(self)
end

#contractsObject



43
44
45
# File 'lib/halo_msp_api/client.rb', line 43

def contracts
  @contracts ||= Resources::Contracts.new(self)
end

#delete(path) ⇒ Object



124
125
126
# File 'lib/halo_msp_api/client.rb', line 124

def delete(path)
  request(:delete, path)
end

#get(path, params = {}) ⇒ Object

HTTP methods



108
109
110
# File 'lib/halo_msp_api/client.rb', line 108

def get(path, params = {})
  request(:get, path, params)
end

#integrationsObject



47
48
49
# File 'lib/halo_msp_api/client.rb', line 47

def integrations
  @integrations ||= Resources::Integrations.new(self)
end

#invoicesObject



51
52
53
# File 'lib/halo_msp_api/client.rb', line 51

def invoices
  @invoices ||= Resources::Invoices.new(self)
end

#knowledge_baseObject



55
56
57
# File 'lib/halo_msp_api/client.rb', line 55

def knowledge_base
  @knowledge_base ||= Resources::KnowledgeBase.new(self)
end

#organisationsObject



59
60
61
# File 'lib/halo_msp_api/client.rb', line 59

def organisations
  @organisations ||= Resources::Organisations.new(self)
end

#patch(path, body = {}) ⇒ Object



120
121
122
# File 'lib/halo_msp_api/client.rb', line 120

def patch(path, body = {})
  request(:patch, path, body)
end

#post(path, body = {}) ⇒ Object



112
113
114
# File 'lib/halo_msp_api/client.rb', line 112

def post(path, body = {})
  request(:post, path, body)
end

#productsObject



63
64
65
# File 'lib/halo_msp_api/client.rb', line 63

def products
  @products ||= Resources::Products.new(self)
end

#purchase_ordersObject



67
68
69
# File 'lib/halo_msp_api/client.rb', line 67

def purchase_orders
  @purchase_orders ||= Resources::PurchaseOrders.new(self)
end

#put(path, body = {}) ⇒ Object



116
117
118
# File 'lib/halo_msp_api/client.rb', line 116

def put(path, body = {})
  request(:put, path, body)
end

#quotationsObject



71
72
73
# File 'lib/halo_msp_api/client.rb', line 71

def quotations
  @quotations ||= Resources::Quotations.new(self)
end

#reportsObject



75
76
77
# File 'lib/halo_msp_api/client.rb', line 75

def reports
  @reports ||= Resources::Reports.new(self)
end

#sales_ordersObject



91
92
93
# File 'lib/halo_msp_api/client.rb', line 91

def sales_orders
  @sales_orders ||= Resources::SalesOrders.new(self)
end

#servicesObject



79
80
81
# File 'lib/halo_msp_api/client.rb', line 79

def services
  @services ||= Resources::Services.new(self)
end

#slasObject



95
96
97
# File 'lib/halo_msp_api/client.rb', line 95

def slas
  @slas ||= Resources::Slas.new(self)
end

#suppliersObject



99
100
101
# File 'lib/halo_msp_api/client.rb', line 99

def suppliers
  @suppliers ||= Resources::Suppliers.new(self)
end

#ticketsObject



83
84
85
# File 'lib/halo_msp_api/client.rb', line 83

def tickets
  @tickets ||= Resources::Tickets.new(self)
end

#usersObject



87
88
89
# File 'lib/halo_msp_api/client.rb', line 87

def users
  @users ||= Resources::Users.new(self)
end

#webhooksObject



103
104
105
# File 'lib/halo_msp_api/client.rb', line 103

def webhooks
  @webhooks ||= Resources::Webhooks.new(self)
end