Class: Nzbn::Api::IndustryClassifications

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

Overview

Industry Classifications API

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ IndustryClassifications

Returns a new instance of IndustryClassifications.



7
8
9
# File 'lib/nzbn/api/industry_classifications.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#create(nzbn:, classification:) ⇒ Models::IndustryClassification

Add an industry classification

Parameters:

  • nzbn (String)

    13-digit NZBN

  • classification (Hash)

    Classification attributes

Returns:



29
30
31
32
# File 'lib/nzbn/api/industry_classifications.rb', line 29

def create(nzbn:, classification:)
  response = @client.post("/entities/#{nzbn}/industry-classifications", classification)
  Models::IndustryClassification.new(response)
end

#list(nzbn:) ⇒ Array<Models::IndustryClassification>

List industry classifications for an entity

Parameters:

  • nzbn (String)

    13-digit NZBN

Returns:



16
17
18
19
20
21
# File 'lib/nzbn/api/industry_classifications.rb', line 16

def list(nzbn:)
  response = @client.get("/entities/#{nzbn}/industry-classifications")
  return [] unless response.is_a?(Array)

  response.map { |ic| Models::IndustryClassification.new(ic) }
end