Sha256: ce50b0b93c966b077c0a0253e96f4080cc1655c12bea17d15911cd1157e65148
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module Acumatica class StockItem < OpenStruct def self.find_all(select: nil, filter: nil, expand: nil, offset: nil, limit: nil) params = {} params['$select'] = select if select params['$filter'] = filter if filter params['$expand'] = expand if expand params['$skip'] = offset if offset params['$top'] = limit if limit response = Acumatica::Client.instance.connection.get do |req| req.url url req.params = params end response.body.map { |attrs| self.new(attrs) } end def self.url URI.join( Acumatica::Client.instance.url, "/entity/Default/#{Acumatica::Client::API_VERSION}/StockItem" ) end def initialize(params = {}) new_params = {} params.each do |k,v| v = v.values.first if v.is_a?(Hash) && v.keys == ["value"] new_params[methodify(k)] = v end super(new_params) self.attributes ||= [] attributes.each { |a| self[methodify(a['AttributeID']['value'])] = a['Value']['value'] } end private def methodify(word) word.gsub(/(.)([A-Z])/,'\1_\2').downcase end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acumatica-0.1.3 | lib/acumatica/stock_item.rb |