Method: CdekClient::Client#pickup_points

Defined in:
lib/cdek_client/client.rb

#pickup_points(params = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cdek_client/client.rb', line 16

def pickup_points(params = {})
  params = normalize_request_data params
  result = request url_for(:primary, :pickup_points), url_for(:secondary, :pickup_points), :get, params
  if result.errors.any?
    result.set_data []
    return result
  end
  if result.data[:PvzList].has_key? :ErrorCode
    error = CdekClient.get_api_error result.data[:PvzList][:ErrorCode], result.data[:PvzList][:Msg]
    result.add_error error
    result.set_data []
  else
    normalized_data = Util.array_wrap result.data[:PvzList][:Pvz]
    normalized_data = normalize_response_data normalized_data, response_normalization_rules_for(:pickup_points)
    result.set_data normalized_data
  end
  result
end