Sha256: 8def4af7c94489695c882ba90125087abf46d14d215f59f81f3fa053165d81d3
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Acumatica class StockItem < OpenStruct def self.create(params) Acumatica::Client.instance.connection.put do |req| req.url url req.body = params end end 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.2.0 | lib/acumatica/stock_item.rb |