Sha256: 8032ee949936a75b0dd753af47d0a885b8894680b977f3af5633460831eef76b
Contents?: true
Size: 956 Bytes
Versions: 59
Compression:
Stored size: 956 Bytes
Contents
module BillHicks # Category item response structure: # # { # code: "...", # ':category_code' in Catalog response. # description: "..." # ':category_description' in Catalog response. # } class Category < Base def initialize(options = {}) requires!(options, :username, :password) @options = options end def self.all(options = {}) requires!(options, :username, :password) new(options).all end # Returns an array of hashes with category details. def all categories = [] # Categories are listed in catalog csv, so fetch that. catalog = Catalog.all(@options) catalog.each do |item| categories << { code: item[:category_code], description: item[:category_description] } end categories.uniq! { |c| c[:description] } categories.sort_by! { |c| c[:description] } categories end end end
Version data entries
59 entries across 59 versions & 1 rubygems