4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/ghtk/order.rb', line 4
def self.create(serializer)
create_data = Ghtk::FlexibleParams.new(serializer).hash
Ghtk::Validations::OrderValidation.new(create_data).validate!
Ghtk::Request.post('/services/shipment/order', create_data)
rescue Ghtk::RequestError => e
error_code = e.response.dig('error', 'code') || 'REQUEST'
error_class = "Ghtk::#{error_code.downcase.classify}Error".safe_constantize || Ghtk::RequestError
raise error_class, e.response
rescue Ghtk::ForbiddenError
raise Ghtk::CreateOrderError.new(create_data)
end
|