Class: Sap::Product

Inherits:
SapAnywhereInterface show all
Defined in:
lib/resource/sap/product.rb

Instance Method Summary collapse

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:

对象初始化方法(初始化来源)

对象初始化方法(初始化来源)

Parameters:

  • source (string)


11
12
13
# File 'lib/resource/sap/product.rb', line 11

def initialize(source)
  @source = source
end

Instance Method Details

#find(id) ⇒ Object

Note:

通过接口获得单个数据

通过接口获得单个数据

Parameters:

  • id (Integer)

    数据id



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 find_attachment(id, attachment_id)
  get(query_attchment(id, attachment_id))
end

#listObject

Note:

通过接口获得一堆数据

通过接口获得一堆数据

Parameters:

  • source (string)

    来源

  • request_name (string)

    请求资源名



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:

通过接口获得单个数据

通过接口获得单个数据

Parameters:

  • id (Integer)

    数据id



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 = {}, attachment_id = {})
  request_names = "#{request_name}/#{id}/Images/#{attachment_id}?"

  {
      source: @source,
      request_name: request_names
  }
end

#request_nameObject

Note:

获取请求路径的请求名

获取请求路径的请求名



44
45
46
# File 'lib/resource/sap/product.rb', line 44

def request_name
  'Products'
end