Class: Uktt::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/uktt/section.rb

Overview

A Section object for dealing with an API resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Section

Returns a new instance of Section.



6
7
8
9
10
# File 'lib/uktt/section.rb', line 6

def initialize(opts = {})
  @section_id = opts[:section_id] || nil
  Uktt.configure(opts.transform_keys(&:to_sym))
  @config = Uktt.config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/uktt/section.rb', line 4

def config
  @config
end

#section_idObject

Returns the value of attribute section_id.



4
5
6
# File 'lib/uktt/section.rb', line 4

def section_id
  @section_id
end

Instance Method Details

#goods_nomenclaturesObject



22
23
24
25
26
# File 'lib/uktt/section.rb', line 22

def goods_nomenclatures
  return '@section_id cannot be nil' if @section_id.nil?

  fetch "#{GOODS_NOMENCLATURE}/section/#{@section_id}.json"
end

#noteObject



28
29
30
31
32
# File 'lib/uktt/section.rb', line 28

def note
  return '@section_id cannot be nil' if @section_id.nil?

  fetch "#{SECTION}/#{@section_id}/section_note.json"
end

#retrieveObject



12
13
14
15
16
# File 'lib/uktt/section.rb', line 12

def retrieve
  return '@section_id cannot be nil' if @section_id.nil?

  fetch "#{SECTION}/#{@section_id}.json"
end

#retrieve_allObject



18
19
20
# File 'lib/uktt/section.rb', line 18

def retrieve_all
  fetch "#{SECTION}.json"
end