Class: Nzbn::Api::Entities
- Inherits:
-
Object
- Object
- Nzbn::Api::Entities
- Defined in:
- lib/nzbn/api/entities.rb
Overview
Entities API - Search and manage NZBN entities
Instance Method Summary collapse
-
#changes(change_event_type:, entity_type: nil, date_time_from: nil, date_time_to: nil, page: nil, page_size: nil, sort_by: nil, sort_order: nil) ⇒ Models::SearchResponse
Search entity changes.
-
#create(entity:) ⇒ Hash
Create a new entity (sole trader, partnership, or trust).
-
#get(nzbn:, if_none_match: nil) ⇒ Models::FullEntity
Get entity by NZBN.
-
#get_discoverable(nzbn:) ⇒ Models::Entity
Get discoverable entity information.
-
#initialize(client) ⇒ Entities
constructor
A new instance of Entities.
-
#search(search_term:, entity_status: nil, entity_type: nil, industry_code: nil, page: nil, page_size: nil) ⇒ Models::SearchResponse
Search entities by name.
-
#update_abn(nzbn:, abn_data:) ⇒ Hash
Update Australian Business Number.
-
#update_status(nzbn:, status:) ⇒ Hash
Update entity status.
Constructor Details
#initialize(client) ⇒ Entities
Returns a new instance of Entities.
7 8 9 |
# File 'lib/nzbn/api/entities.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#changes(change_event_type:, entity_type: nil, date_time_from: nil, date_time_to: nil, page: nil, page_size: nil, sort_by: nil, sort_order: nil) ⇒ Models::SearchResponse
Search entity changes
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nzbn/api/entities.rb', line 75 def changes(change_event_type:, entity_type: nil, date_time_from: nil, date_time_to: nil, page: nil, page_size: nil, sort_by: nil, sort_order: nil) params = { 'change-event-type' => change_event_type } params['entity-type'] = entity_type if entity_type params['date-time-from'] = date_time_from if date_time_from params['date-time-to'] = date_time_to if date_time_to params['page'] = page if page params['page-size'] = page_size if page_size params['sort-by'] = sort_by if sort_by params['sort-order'] = sort_order if sort_order response = @client.get('/entities/changes', params) Models::SearchResponse.new(response, item_class: Models::SearchEntity) end |
#create(entity:) ⇒ Hash
Create a new entity (sole trader, partnership, or trust)
95 96 97 |
# File 'lib/nzbn/api/entities.rb', line 95 def create(entity:) @client.post('/entities', entity) end |
#get(nzbn:, if_none_match: nil) ⇒ Models::FullEntity
Get entity by NZBN
45 46 47 48 49 50 51 |
# File 'lib/nzbn/api/entities.rb', line 45 def get(nzbn:, if_none_match: nil) headers = {} headers['If-None-Match'] = if_none_match if if_none_match response = @client.get("/entities/#{nzbn}", {}, headers) Models::FullEntity.new(response) end |
#get_discoverable(nzbn:) ⇒ Models::Entity
Get discoverable entity information
58 59 60 61 |
# File 'lib/nzbn/api/entities.rb', line 58 def get_discoverable(nzbn:) response = @client.get("/entities/#{nzbn}/discoverable") Models::Entity.new(response) end |
#search(search_term:, entity_status: nil, entity_type: nil, industry_code: nil, page: nil, page_size: nil) ⇒ Models::SearchResponse
Search entities by name
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nzbn/api/entities.rb', line 24 def search(search_term:, entity_status: nil, entity_type: nil, industry_code: nil, page: nil, page_size: nil) params = { 'search-term' => search_term } params['entity-status'] = entity_status if entity_status params['entity-type'] = entity_type if entity_type params['industry-code'] = industry_code if industry_code params['page'] = page if page params['page-size'] = page_size if page_size response = @client.get('/entities', params) Models::SearchResponse.new(response, item_class: Models::SearchEntity) end |
#update_abn(nzbn:, abn_data:) ⇒ Hash
Update Australian Business Number
115 116 117 |
# File 'lib/nzbn/api/entities.rb', line 115 def update_abn(nzbn:, abn_data:) @client.put("/entities/#{nzbn}/australian-business-number", abn_data) end |
#update_status(nzbn:, status:) ⇒ Hash
Update entity status
105 106 107 |
# File 'lib/nzbn/api/entities.rb', line 105 def update_status(nzbn:, status:) @client.post("/entities/#{nzbn}/entity-statuses", status) end |