Class: Sap::Product
- Inherits:
-
SapAnywhereInterface
- Object
- SapAnywhereInterface
- Sap::Product
- Defined in:
- lib/resource/sap/product.rb
Instance Method Summary collapse
-
#find(id) ⇒ Object
通过接口获得单个数据.
- #find_attachment(id, attachment_id) ⇒ Object
-
#initialize(source) ⇒ Product
constructor
对象初始化方法(初始化来源).
-
#list ⇒ Object
通过接口获得一堆数据.
- #post_params(id) ⇒ Object
- #post_query(id) ⇒ Object
-
#posts(id) ⇒ Object
通过接口获得单个数据.
- #query(id = {}) ⇒ Object
- #query_attchment(id = {}, attachment_id = {}) ⇒ Object
-
#request_name ⇒ Object
获取请求路径的请求名.
Methods inherited from SapAnywhereInterface
#check_access_token, #check_function_and_shop, #convert_payment_type, #convert_price_unit, #delete, #get, #get_access_token, #get_access_token_url, #handle_response, #patch, #post
Constructor Details
#initialize(source) ⇒ Product
Note:
对象初始化方法(初始化来源)
对象初始化方法(初始化来源)
11 12 13 |
# File 'lib/resource/sap/product.rb', line 11 def initialize(source) @source = source end |
Instance Method Details
#find(id) ⇒ Object
Note:
通过接口获得单个数据
通过接口获得单个数据
28 29 30 |
# File 'lib/resource/sap/product.rb', line 28 def find(id) get(query(id)) end |
#find_attachment(id, attachment_id) ⇒ Object
38 39 40 |
# File 'lib/resource/sap/product.rb', line 38 def (id, ) get(query_attchment(id, )) end |
#list ⇒ Object
Note:
通过接口获得一堆数据
通过接口获得一堆数据
21 22 23 |
# File 'lib/resource/sap/product.rb', line 21 def list get(query) end |
#post_params(id) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/resource/sap/product.rb', line 70 def post_params(id) disableInventory = Hashie::Mash.new disableInventory.id = id disableInventory end |
#post_query(id) ⇒ Object
77 78 79 80 81 82 83 84 |
# 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) ⇒ Object
Note:
通过接口获得单个数据
通过接口获得单个数据
35 36 37 |
# File 'lib/resource/sap/product.rb', line 35 def posts(id) post(post_query(id), post_params(id).to_json) end |
#query(id = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# 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 = {}) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/resource/sap/product.rb', line 61 def query_attchment(id = {}, = {}) request_names = "#{request_name}/#{id}/Images/#{}?" { source: @source, request_name: request_names } end |
#request_name ⇒ Object
Note:
获取请求路径的请求名
获取请求路径的请求名
44 45 46 |
# File 'lib/resource/sap/product.rb', line 44 def request_name 'Products' end |