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.



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

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.



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

def configuration
  @configuration
end

Instance Method Details

#addressesObject



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

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

#company_detailsObject



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

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

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



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

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

#email_addressesObject



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

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

#entitiesObject

API Resource Accessors



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

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

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

HTTP Methods



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

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

#historyObject



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

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

#industry_classificationsObject



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

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

#organisation_partsObject



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

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

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



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

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

#phone_numbersObject



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

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

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



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

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

#privacy_settingsObject



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

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

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



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

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

#rolesObject



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

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

#trading_namesObject



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

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

#watchlistsObject



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

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

#websitesObject



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

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