Sha256: 18054f21b2daa9014c30e7a5c59292e96dce8d9ab535b711d4beeeb126271012
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
module Uktt # A Chapter object for dealing with an API resource class Chapter attr_accessor :config, :chapter_id def initialize(opts = {}) @chapter_id = opts[:chapter_id] || nil Uktt.configure(opts) @config = Uktt.config end def retrieve return '@chapter_id cannot be nil' if @chapter_id.nil? fetch "#{CHAPTER}/#{@chapter_id}.json" end def retrieve_all fetch "#{CHAPTER}.json" end def goods_nomenclatures return '@chapter_id cannot be nil' if @chapter_id.nil? fetch "#{GOODS_NOMENCLATURE}/chapter/#{@chapter_id}.json" end def changes return '@chapter_id cannot be nil' if @chapter_id.nil? fetch "#{CHAPTER}/#{@chapter_id}/changes.json" end def note return '@chapter_id cannot be nil' if @chapter_id.nil? fetch "#{CHAPTER}/#{@chapter_id}/chapter_note.json" end def config=(new_opts = {}) merged_opts = Uktt.config.merge(new_opts) Uktt.configure merged_opts @chapter_id = merged_opts[:chapter_id] || @chapter_id @config = Uktt.config end private def fetch(resource) Uktt::Http.new(@config[:host], @config[:version], @config[:debug]) .retrieve(resource, @config[:return_json]) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uktt-0.2.15 | lib/uktt/chapter.rb |
uktt-0.2.14 | lib/uktt/chapter.rb |