class Sap::Product
Public Class Methods
new(source)
click to toggle source
对象初始化方法(初始化来源) @note 对象初始化方法(初始化来源) @param source [string]
# File lib/resource/sap/product.rb, line 11 def initialize(source) @source = source end
Public Instance Methods
find(id)
click to toggle source
通过接口获得单个数据 @note 通过接口获得单个数据 @param id [Integer] 数据id
# File lib/resource/sap/product.rb, line 28 def find(id) get(query(id)) end
find_attachment(id, attachment_id)
click to toggle source
# File lib/resource/sap/product.rb, line 38 def find_attachment(id, attachment_id) get(query_attchment(id, attachment_id)) end
list()
click to toggle source
通过接口获得一堆数据 @note 通过接口获得一堆数据 @param source [string] 来源 @param request_name
[string] 请求资源名
# File lib/resource/sap/product.rb, line 21 def list get(query) end
post_params(id)
click to toggle source
# File lib/resource/sap/product.rb, line 70 def post_params(id) disableInventory = Hashie::Mash.new disableInventory.id = id disableInventory end
post_query(id)
click to toggle source
# File lib/resource/sap/product.rb, line 77 def post_query(id) request_names = "#{request_name}/#{id}/disableInventory?" { source: @source, request_name: request_names } end
posts(id)
click to toggle source
通过接口获得单个数据 @note 通过接口获得单个数据 @param id [Integer] 数据id
# File lib/resource/sap/product.rb, line 35 def posts(id) post(post_query(id), post_params(id).to_json) end
query(id = {})
click to toggle source
# File lib/resource/sap/product.rb, line 49 def query(id = {}) request_names = if id.present? "#{request_name}/#{id}?expand=*&" else "#{request_name}?expand=skus&" end { source: @source, request_name: request_names } end
query_attchment(id = {}, attachment_id = {})
click to toggle source
# File lib/resource/sap/product.rb, line 61 def query_attchment(id = {}, attachment_id = {}) request_names = "#{request_name}/#{id}/Images/#{attachment_id}?" { source: @source, request_name: request_names } end
request_name()
click to toggle source
获取请求路径的请求名 @note 获取请求路径的请求名
# File lib/resource/sap/product.rb, line 44 def request_name 'Products' end