Class: Uktt::Chapter

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

Overview

A Chapter object for dealing with an API resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Chapter

Returns a new instance of Chapter.



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

def initialize(opts = {})
  @chapter_id = opts[:chapter_id] || nil
  Uktt.configure(opts)
  @config = Uktt.config
end

Instance Attribute Details

#chapter_idObject

Returns the value of attribute chapter_id.



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

def chapter_id
  @chapter_id
end

#configObject

Returns the value of attribute config.



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

def config
  @config
end

Instance Method Details

#changesObject



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

def changes
  return '@chapter_id cannot be nil' if @chapter_id.nil?

  fetch "#{CHAPTER}/#{@chapter_id}/changes.json"
end

#goods_nomenclaturesObject



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

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

  fetch "#{GOODS_NOMENCLATURE}/chapter/#{@chapter_id}.json"
end

#noteObject



34
35
36
37
38
# File 'lib/uktt/chapter.rb', line 34

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

  fetch "#{CHAPTER}/#{@chapter_id}/chapter_note.json"
end

#retrieveObject



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

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

  fetch "#{CHAPTER}/#{@chapter_id}.json"
end

#retrieve_allObject



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

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