Class: Sap::SalesDelivery
- Inherits:
-
SapAnywhereInterface
- Object
- SapAnywhereInterface
- Sap::SalesDelivery
- Defined in:
- lib/resource/sap/sales_delivery.rb
Instance Method Summary collapse
-
#find(id, params = {}) ⇒ Object
通过接口获得单个数据.
-
#initialize(source) ⇒ SalesDelivery
constructor
对象初始化方法(初始化来源).
-
#list ⇒ Object
通过接口获得一堆数据.
-
#query(id = {}, params = {}) ⇒ Object
设置请求的路径,过滤条件为当前时间的前12小时生成的物流.
-
#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) ⇒ SalesDelivery
Note:
对象初始化方法(初始化来源)
对象初始化方法(初始化来源)
11 12 13 |
# File 'lib/resource/sap/sales_delivery.rb', line 11 def initialize(source) @source = source end |
Instance Method Details
#find(id, params = {}) ⇒ Object
Note:
通过接口获得单个数据
通过接口获得单个数据
28 29 30 |
# File 'lib/resource/sap/sales_delivery.rb', line 28 def find(id, params = {}) get(query(id, params)) end |
#list ⇒ Object
Note:
通过接口获得一堆数据
通过接口获得一堆数据
21 22 23 |
# File 'lib/resource/sap/sales_delivery.rb', line 21 def list get(query) end |
#query(id = {}, params = {}) ⇒ Object
Note:
设置请求的路径,过滤条件为当前时间的前12小时生成的物流 @param id [Integer]物流id
设置请求的路径,过滤条件为当前时间的前12小时生成的物流
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/resource/sap/sales_delivery.rb', line 42 def query(id = {}, params = {}) #临时先这样写 因为sap的物流时间有bug # before_now_five_min = (Time.now.strftime('%M').to_i).to_s before_now_hour = Time.now.strftime('%H').to_i before_now_day = Time.now.strftime('%d').to_i # if before_now_five_min < 0 # before_now_five_min = (before_now_five_min + 60).to_s # before_now_hour = (before_now_hour - 1).to_s # else # before_now_five_min = before_now_five_min.to_s # before_now_hour = before_now_hour.to_s # end if before_now_hour >= 12 before_now_hour = (before_now_hour - 12).to_s before_now_hour = "0#{before_now_hour}" before_now_day = before_now_day.to_s else before_now_hour = (before_now_hour + 12).to_s before_now_day = (before_now_day - 1).to_s end time = Time.now.strftime("%Y-%m-#{before_now_day}T#{before_now_hour}:#{Time.now.strftime('%M')}:%S.000Z").to_s request_names = if id.present? "#{request_name}/#{id}?expand=*&" else "#{request_name}?filter=creationTime+gt+'#{time}'&expand=*&" end Rails.logger.info "request_names#{request_names}" { source: @source, request_name: request_names } end |
#request_name ⇒ Object
Note:
获取请求路径的请求名
获取请求路径的请求名
34 35 36 |
# File 'lib/resource/sap/sales_delivery.rb', line 34 def request_name 'SalesDeliveries' end |