Class: Nzbn::Client

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

Overview

Main HTTP client for NZBN API

Examples:

client = Nzbn::Client.new
client.entities.search(search_term: 'Company Name')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, base_url: nil, timeout: nil) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
25
# File 'lib/nzbn/client.rb', line 18

def initialize(api_key: nil, base_url: nil, timeout: nil)
  @configuration = Nzbn.configuration&.dup || Configuration.new
  @configuration.api_key = api_key if api_key
  @configuration.base_url = base_url if base_url
  @configuration.timeout = timeout if timeout

  validate_configuration!
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



16
17
18
# File 'lib/nzbn/client.rb', line 16

def configuration
  @configuration
end

Instance Method Details

#addressesObject



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

def addresses
  @addresses ||= Api::Addresses.new(self)
end

#company_detailsObject



65
66
67
# File 'lib/nzbn/client.rb', line 65

def company_details
  @company_details ||= Api::CompanyDetails.new(self)
end

#delete(path, params = {}, headers = {}) ⇒ Object



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

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

#email_addressesObject



49
50
51
# File 'lib/nzbn/client.rb', line 49

def email_addresses
  @email_addresses ||= Api::EmailAddresses.new(self)
end

#entitiesObject

API Resource Accessors



29
30
31
# File 'lib/nzbn/client.rb', line 29

def entities
  @entities ||= Api::Entities.new(self)
end

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

HTTP Methods



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

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

#historyObject



77
78
79
# File 'lib/nzbn/client.rb', line 77

def history
  @history ||= Api::History.new(self)
end

#industry_classificationsObject



57
58
59
# File 'lib/nzbn/client.rb', line 57

def industry_classifications
  @industry_classifications ||= Api::IndustryClassifications.new(self)
end

#organisation_partsObject



73
74
75
# File 'lib/nzbn/client.rb', line 73

def organisation_parts
  @organisation_parts ||= Api::OrganisationParts.new(self)
end

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



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

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

#phone_numbersObject



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

def phone_numbers
  @phone_numbers ||= Api::PhoneNumbers.new(self)
end

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



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

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

#privacy_settingsObject



61
62
63
# File 'lib/nzbn/client.rb', line 61

def privacy_settings
  @privacy_settings ||= Api::PrivacySettings.new(self)
end

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



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

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

#rolesObject



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

def roles
  @roles ||= Api::Roles.new(self)
end

#trading_namesObject



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

def trading_names
  @trading_names ||= Api::TradingNames.new(self)
end

#watchlistsObject



69
70
71
# File 'lib/nzbn/client.rb', line 69

def watchlists
  @watchlists ||= Api::Watchlists.new(self)
end

#websitesObject



53
54
55
# File 'lib/nzbn/client.rb', line 53

def websites
  @websites ||= Api::Websites.new(self)
end