class ShipitAPI::Commune

Public Class Methods

all(opts = {}) click to toggle source
# File lib/shipit_api/commune.rb, line 7
def self.all(opts = {})
  new(opts).all
end
find(opts = {}) click to toggle source
# File lib/shipit_api/commune.rb, line 3
def self.find(opts = {})
  new().find(opts)
end
find_by_name(opts = {}) click to toggle source
# File lib/shipit_api/commune.rb, line 11
def self.find_by_name(opts = {})
  new().find_by_name(opts)
end
new(opts = {}) click to toggle source
# File lib/shipit_api/commune.rb, line 15
def initialize(opts = {})
  @opts = opts
  @api_call = ShipitAPI::Session.connection(self.class.name)
end

Public Instance Methods

all() click to toggle source
# File lib/shipit_api/commune.rb, line 20
def all
  response = @api_call.get('', @opts)
  JSON.parse(response.body)
end
find(opts = {}) click to toggle source
# File lib/shipit_api/commune.rb, line 25
def find(opts = {})
  opts = opts.empty? ? StandardError : opts
  response = @api_call.get("#{opts[:id]}")
  JSON.parse(response.body, symbolize_names: true)
end
find_by_name(opts = {}) click to toggle source
# File lib/shipit_api/commune.rb, line 31
def find_by_name(opts = {})
  opts = opts.empty? ? StandarError : opts
  commune = URI.encode(opts[:name])
  response = @api_call.get("by_name/#{commune}")
  JSON.parse(response.body, symbolize_names: true)
end