conekta 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG +9 -1
- data/Gemfile +1 -0
- data/README.md +68 -46
- data/lib/conekta.rb +20 -1
- data/lib/conekta/address.rb +1 -0
- data/lib/conekta/card.rb +17 -3
- data/lib/conekta/charge.rb +7 -0
- data/lib/conekta/conekta_object.rb +25 -8
- data/lib/conekta/customer.rb +55 -4
- data/lib/conekta/destination.rb +29 -0
- data/lib/conekta/discount_line.rb +32 -0
- data/lib/conekta/error.rb +35 -37
- data/lib/conekta/error_list.rb +33 -0
- data/lib/conekta/event.rb +4 -1
- data/lib/conekta/fiscal_entity.rb +37 -0
- data/lib/conekta/line_item.rb +30 -0
- data/lib/conekta/list.rb +59 -0
- data/lib/conekta/log.rb +4 -0
- data/lib/conekta/operations/create_member.rb +20 -10
- data/lib/conekta/operations/custom_action.rb +1 -1
- data/lib/conekta/operations/delete.rb +3 -1
- data/lib/conekta/operations/where.rb +11 -2
- data/lib/conekta/order.rb +90 -0
- data/lib/conekta/payee.rb +4 -0
- data/lib/conekta/payment_source.rb +30 -0
- data/lib/conekta/payout_method.rb +12 -3
- data/lib/conekta/plan.rb +5 -0
- data/lib/conekta/refund.rb +2 -0
- data/lib/conekta/requestor.rb +14 -4
- data/lib/conekta/resource.rb +26 -4
- data/lib/conekta/return.rb +25 -0
- data/lib/conekta/shipping_contact.rb +32 -0
- data/lib/conekta/shipping_line.rb +33 -0
- data/lib/conekta/subscription.rb +17 -3
- data/lib/conekta/tax_line.rb +30 -0
- data/lib/conekta/token.rb +2 -0
- data/lib/conekta/util.rb +37 -3
- data/lib/conekta/version.rb +1 -1
- data/lib/conekta/webhook.rb +2 -0
- data/spec/conekta/1.0.0/.DS_Store +0 -0
- data/spec/conekta/1.0.0/card_spec.rb +40 -0
- data/spec/conekta/{charge_spec.rb → 1.0.0/charge_spec.rb} +1 -0
- data/spec/conekta/{customer_spec.rb → 1.0.0/customer_spec.rb} +3 -2
- data/spec/conekta/{error_spec.rb → 1.0.0/error_spec.rb} +3 -1
- data/spec/conekta/{event_spec.rb → 1.0.0/event_spec.rb} +1 -0
- data/spec/conekta/{log_spec.rb → 1.0.0/log_spec.rb} +1 -0
- data/spec/conekta/{payout_spec.rb → 1.0.0/payout_spec.rb} +1 -0
- data/spec/conekta/{plan_spec.rb → 1.0.0/plan_spec.rb} +1 -0
- data/spec/conekta/{token_spec.rb → 1.0.0/token_spec.rb} +1 -0
- data/spec/conekta/{webhook_spec.rb → 1.0.0/webhook_spec.rb} +1 -0
- data/spec/conekta/2.0.0/customer_spec.rb +49 -0
- data/spec/conekta/2.0.0/discount_line_spec.rb +49 -0
- data/spec/conekta/2.0.0/error_list_spec.rb +45 -0
- data/spec/conekta/2.0.0/fiscal_entity_spec.rb +67 -0
- data/spec/conekta/2.0.0/line_item_spec.rb +53 -0
- data/spec/conekta/2.0.0/list_spec.rb +29 -0
- data/spec/conekta/2.0.0/order_spec.rb +327 -0
- data/spec/conekta/{payee_spec.rb → 2.0.0/payee_spec.rb} +1 -1
- data/spec/conekta/2.0.0/shipping_contact_spec.rb +60 -0
- data/spec/conekta/2.0.0/shipping_line_spec.rb +53 -0
- data/spec/conekta/2.0.0/source_spec.rb +31 -0
- data/spec/conekta/2.0.0/tax_line_spec.rb +44 -0
- data/spec/conekta_spec.rb +6 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/fixtures/orders.json +2394 -0
- data/spec/support/shared_context.rb +49 -0
- metadata +62 -21
@@ -0,0 +1,29 @@
|
|
1
|
+
module Conekta
|
2
|
+
class Destination < Resource
|
3
|
+
include Conekta::Operations::Delete
|
4
|
+
include Conekta::Operations::Update
|
5
|
+
include Conekta::Operations::CustomAction
|
6
|
+
|
7
|
+
attr_accessor :payee_id, :created_at, :type, :currency,
|
8
|
+
:last4, :account_holder_name, :bank
|
9
|
+
|
10
|
+
def _url
|
11
|
+
if (id.nil? || id.to_s.empty?)
|
12
|
+
exception = Error.new({
|
13
|
+
"message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
|
14
|
+
"message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
|
15
|
+
})
|
16
|
+
if Conekta.api_version == "2.0.0"
|
17
|
+
error_list = Conekta::ErrorList.new
|
18
|
+
error_list.details << exception
|
19
|
+
exception = error_list
|
20
|
+
end
|
21
|
+
raise exception
|
22
|
+
end
|
23
|
+
self.payee._url + self.class._url + "/" + id
|
24
|
+
end
|
25
|
+
def delete
|
26
|
+
self.delete_member('payee','destinations')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Conekta
|
2
|
+
class DiscountLine < Resource
|
3
|
+
include Conekta::Operations::Delete
|
4
|
+
include Conekta::Operations::Update
|
5
|
+
include Conekta::Operations::CustomAction
|
6
|
+
|
7
|
+
attr_accessor :code, :amount, :type, :parent_id
|
8
|
+
|
9
|
+
def _url
|
10
|
+
if (id.nil? || id.to_s.empty?)
|
11
|
+
exception = Error.new({
|
12
|
+
"message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
|
13
|
+
"message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
|
14
|
+
})
|
15
|
+
|
16
|
+
if Conekta.api_version == "2.0.0"
|
17
|
+
error_list = Conekta::ErrorList.new
|
18
|
+
error_list.details << exception
|
19
|
+
exception = error_list
|
20
|
+
end
|
21
|
+
|
22
|
+
raise exception
|
23
|
+
end
|
24
|
+
|
25
|
+
"#{self.order._url}#{self.class._url}/#{id}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete
|
29
|
+
self.delete_member('order', 'discount_lines')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/conekta/error.rb
CHANGED
@@ -1,49 +1,47 @@
|
|
1
1
|
module Conekta
|
2
2
|
class Error < Exception
|
3
|
-
attr_reader :message
|
4
|
-
|
3
|
+
attr_reader :message, :message_to_purchaser, :param, :code
|
4
|
+
# NEW FIELDS
|
5
|
+
attr_reader :validation_error, :custom_message
|
6
|
+
# <b>DEPRECATED</b>.
|
5
7
|
attr_reader :type
|
6
|
-
|
7
|
-
attr_reader :param
|
8
|
+
|
8
9
|
|
9
|
-
def initialize(
|
10
|
-
@message = message
|
11
|
-
@message_to_purchaser = message_to_purchaser
|
12
|
-
@
|
13
|
-
@code = code
|
14
|
-
@
|
10
|
+
def initialize(options={})
|
11
|
+
@message = options["message"]
|
12
|
+
@message_to_purchaser = options["message_to_purchaser"]
|
13
|
+
@param = options["param"]
|
14
|
+
@code = options["code"]
|
15
|
+
@validation_error = options["validation_error"]
|
16
|
+
@validation_error = options["custom_message"]
|
17
|
+
@type = options["type"]
|
15
18
|
end
|
16
19
|
def class_name
|
17
20
|
self.class.name.split('::')[-1]
|
18
21
|
end
|
19
|
-
def self.error_handler(
|
20
|
-
if
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@param = resp["param"] if resp.has_key?('param')
|
26
|
-
end
|
27
|
-
if code == nil or code == 0 or code == nil or code == ""
|
28
|
-
raise NoConnectionError.new(
|
29
|
-
I18n.t('error.requestor.connection', { base: Conekta.api_base, locale: :en }),
|
30
|
-
I18n.t('error.requestor.connection_purchaser', { locale: Conekta.locale.to_sym }))
|
31
|
-
end
|
32
|
-
case code
|
33
|
-
when 400
|
34
|
-
raise MalformedRequestError.new(@message, @message_to_purchaser, @type, @code, @params)
|
35
|
-
when 401
|
36
|
-
raise AuthenticationError.new(@message, @message_to_purchaser, @type, @code, @params)
|
37
|
-
when 402
|
38
|
-
raise ProcessingError.new(@message, @message_to_purchaser, @type, @code, @params)
|
39
|
-
when 404
|
40
|
-
raise ResourceNotFoundError.new(@message, @message_to_purchaser, @type, @code, @params)
|
41
|
-
when 422
|
42
|
-
raise ParameterValidationError.new(@message, @message_to_purchaser, @type, @code, @params)
|
43
|
-
when 500
|
44
|
-
raise ApiError.new(@message, @message_to_purchaser, @type, @code, @params)
|
22
|
+
def self.error_handler(response, http_status)
|
23
|
+
if http_status.to_s.empty? || http_status == 0
|
24
|
+
NoConnectionError.new({
|
25
|
+
"message" => I18n.t('error.requestor.connection', { base: Conekta.api_base, locale: :en }),
|
26
|
+
"message_to_purchaser" => I18n.t('error.requestor.connection_purchaser', { locale: Conekta.locale.to_sym })
|
27
|
+
})
|
45
28
|
else
|
46
|
-
|
29
|
+
case http_status
|
30
|
+
when 400
|
31
|
+
MalformedRequestError.new(response)
|
32
|
+
when 401
|
33
|
+
AuthenticationError.new(response)
|
34
|
+
when 402
|
35
|
+
ProcessingError.new(response)
|
36
|
+
when 404
|
37
|
+
ResourceNotFoundError.new(response)
|
38
|
+
when 422
|
39
|
+
ParameterValidationError.new(response)
|
40
|
+
when 500
|
41
|
+
ApiError.new(response)
|
42
|
+
else
|
43
|
+
Error.new(response)
|
44
|
+
end
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Conekta
|
2
|
+
class ErrorList < Exception
|
3
|
+
attr_accessor :details
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@details = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.error_handler(response, http_status)
|
10
|
+
exception = nil
|
11
|
+
if response.instance_of?(Hash)
|
12
|
+
if response.has_key?("details")
|
13
|
+
error_list = ErrorList.new
|
14
|
+
response["details"].each do |error|
|
15
|
+
error_list.details << self.build_error(error, http_status)
|
16
|
+
end
|
17
|
+
error_list.details << self.build_error(nil, nil) if error_list.details.empty?
|
18
|
+
exception = error_list
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
exception ||= self.build_error(response, http_status)
|
23
|
+
|
24
|
+
raise exception
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def self.build_error(response, http_status)
|
30
|
+
Error.error_handler(response, http_status)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/conekta/event.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Conekta
|
2
|
+
class FiscalEntity < Resource
|
3
|
+
include Conekta::Operations::Delete
|
4
|
+
include Conekta::Operations::Update
|
5
|
+
include Conekta::Operations::CustomAction
|
6
|
+
|
7
|
+
attr_accessor :tax_id, :company_name, :phone, :email, :created_at,
|
8
|
+
:parent_id, :default
|
9
|
+
|
10
|
+
def _url
|
11
|
+
if (id.nil? || id.to_s.empty?)
|
12
|
+
exception = Error.new({
|
13
|
+
"message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
|
14
|
+
"message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
|
15
|
+
})
|
16
|
+
|
17
|
+
if Conekta.api_version == "2.0.0"
|
18
|
+
error_list = Conekta::ErrorList.new
|
19
|
+
error_list.details << exception
|
20
|
+
exception = error_list
|
21
|
+
end
|
22
|
+
|
23
|
+
raise exception
|
24
|
+
end
|
25
|
+
|
26
|
+
self.send(parent)._url + "/fiscal_entities/" + id
|
27
|
+
end
|
28
|
+
|
29
|
+
def parent
|
30
|
+
self.respond_to?(:order) ? "order" : "customer"
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete
|
34
|
+
self.delete_member(parent,'fiscal_entities')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/conekta/line_item.rb
CHANGED
@@ -1,4 +1,34 @@
|
|
1
1
|
module Conekta
|
2
2
|
class LineItem < Resource
|
3
|
+
include Conekta::Operations::Delete
|
4
|
+
include Conekta::Operations::Update
|
5
|
+
include Conekta::Operations::CustomAction
|
6
|
+
|
7
|
+
attr_accessor :name, :description, :unit_price, :quantity,
|
8
|
+
:sku, :shippable, :tags, :brand, :type,
|
9
|
+
:parent_id
|
10
|
+
|
11
|
+
def _url
|
12
|
+
if (id.nil? || id.to_s.empty?)
|
13
|
+
exception = Error.new({
|
14
|
+
"message" => I18n.t('error.resource.id', { resource: self.class.class_name, locale: :en }),
|
15
|
+
"message_to_purchaser" => I18n.t('error.resource.id_purchaser', { locale: Conekta.locale.to_sym })
|
16
|
+
})
|
17
|
+
|
18
|
+
if Conekta.api_version == "2.0.0"
|
19
|
+
error_list = Conekta::ErrorList.new
|
20
|
+
error_list.details << exception
|
21
|
+
exception = error_list
|
22
|
+
end
|
23
|
+
|
24
|
+
raise exception
|
25
|
+
end
|
26
|
+
|
27
|
+
"#{self.order._url}#{self.class._url}/#{id}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete
|
31
|
+
self.delete_member('order','line_items')
|
32
|
+
end
|
3
33
|
end
|
4
34
|
end
|
data/lib/conekta/list.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Conekta
|
2
|
+
class List < ConektaObject
|
3
|
+
attr_reader :elements_type, :params, :has_more, :total
|
4
|
+
|
5
|
+
def initialize(elements_type, params)
|
6
|
+
super()
|
7
|
+
@elements_type = elements_type
|
8
|
+
@params = (params || {})
|
9
|
+
@total = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_element(element)
|
13
|
+
element =
|
14
|
+
Conekta::Util.convert_to_conekta_object(element['object'], element)
|
15
|
+
|
16
|
+
self[@total] = element
|
17
|
+
self.values[@total] = element
|
18
|
+
@total = @total + 1
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def next(options={})
|
24
|
+
if self.size > 0
|
25
|
+
@params["next"] = self.last.id
|
26
|
+
end
|
27
|
+
|
28
|
+
@params["previous"] = nil
|
29
|
+
|
30
|
+
move_cursor(options[:limit])
|
31
|
+
end
|
32
|
+
|
33
|
+
def previous(options={})
|
34
|
+
if self.size > 0
|
35
|
+
@params["previous"] = self.first.id
|
36
|
+
end
|
37
|
+
|
38
|
+
@params["next"] = nil
|
39
|
+
|
40
|
+
move_cursor(options[:limit])
|
41
|
+
end
|
42
|
+
|
43
|
+
def load_from(response)
|
44
|
+
@has_more = response["has_more"]
|
45
|
+
@total = response["total"]
|
46
|
+
self.map{|key, _| self.unset_key(key) }
|
47
|
+
super(response["data"])
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def move_cursor(limit)
|
53
|
+
@params["limit"] = limit if !limit.nil? && !limit.to_s.empty?
|
54
|
+
_url = Util.types[@elements_type.downcase]._url
|
55
|
+
response = Requestor.new.request(:get, _url, @params)
|
56
|
+
self.load_from(response)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/conekta/log.rb
CHANGED
@@ -2,5 +2,9 @@ module Conekta
|
|
2
2
|
class Log < Resource
|
3
3
|
include Conekta::Operations::Where
|
4
4
|
include Conekta::Operations::Find
|
5
|
+
|
6
|
+
attr_accessor :method, :url, :status, :version, :ip_address, :related,
|
7
|
+
:request_body, :response_body, :request_headers,
|
8
|
+
:response_headers, :created_at, :query_string
|
5
9
|
end
|
6
10
|
end
|
@@ -2,19 +2,28 @@ module Conekta
|
|
2
2
|
module Operations
|
3
3
|
module CreateMember
|
4
4
|
def create_member(member, params)
|
5
|
-
_url
|
6
|
-
member
|
5
|
+
_url = [self._url, member].join('/')
|
6
|
+
member = member.to_sym
|
7
7
|
response = Requestor.new.request(:post, _url, params)
|
8
8
|
|
9
|
-
if self.
|
9
|
+
if self.send(member) &&
|
10
|
+
(self.send(member).class.class_name == "ConektaObject" ||
|
11
|
+
self.send(member).class.class_name == "List")
|
10
12
|
arr = []
|
11
|
-
|
12
|
-
|
13
|
+
|
14
|
+
if self.send(member).class.class_name == "List"
|
15
|
+
self.send(member).add_element(response)
|
16
|
+
else
|
17
|
+
self.method(member).call.values.each do |_,v|
|
18
|
+
arr << v.to_hash
|
19
|
+
end
|
20
|
+
|
21
|
+
arr << response
|
22
|
+
self.send(member).load_from(arr)
|
23
|
+
self.load_from
|
13
24
|
end
|
14
|
-
|
15
|
-
self.
|
16
|
-
self.load_from
|
17
|
-
instances = self.method(member).call
|
25
|
+
|
26
|
+
instances = self.send(member)
|
18
27
|
instance = instances.last
|
19
28
|
else
|
20
29
|
instance = Util.types[member.to_s].new()
|
@@ -23,8 +32,9 @@ module Conekta
|
|
23
32
|
self.set_val(member.to_sym, instance)
|
24
33
|
self.load_from
|
25
34
|
end
|
35
|
+
|
26
36
|
instance
|
27
37
|
end
|
28
38
|
end
|
29
39
|
end
|
30
|
-
end
|
40
|
+
end
|
@@ -2,7 +2,7 @@ module Conekta
|
|
2
2
|
module Operations
|
3
3
|
module CustomAction
|
4
4
|
def custom_action(method, action=nil, params=nil)
|
5
|
-
_url
|
5
|
+
_url = action ? [self._url, action].join('/') : self._url
|
6
6
|
response = Requestor.new.request(method, _url, params)
|
7
7
|
|
8
8
|
self.load_from(response)
|
@@ -7,9 +7,11 @@ module Conekta
|
|
7
7
|
end
|
8
8
|
def delete_member(parent, member)
|
9
9
|
self.custom_action(:delete, nil, nil)
|
10
|
+
|
10
11
|
parent = parent.to_sym
|
11
12
|
member = member.to_sym
|
12
|
-
obj
|
13
|
+
obj = self.method(parent).call.method(member).call
|
14
|
+
|
13
15
|
if obj.class.class_name == "ConektaObject"
|
14
16
|
self.method(parent).call.method(member).call.each do |(k, v)|
|
15
17
|
if v.id == self.id
|
@@ -1,11 +1,20 @@
|
|
1
1
|
module Conekta
|
2
2
|
module Operations
|
3
3
|
module Where
|
4
|
+
|
5
|
+
def self.handle_type_of_paging(response, class_name, params)
|
6
|
+
if response.kind_of?(Hash) && response["object"] == "list"
|
7
|
+
List.new(class_name, params)
|
8
|
+
else
|
9
|
+
ConektaObject.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
4
13
|
module ClassMethods
|
5
14
|
def where(params=nil)
|
6
|
-
instance = ConektaObject.new
|
7
15
|
_url = Util.types[self.class_name.downcase]._url
|
8
16
|
response = Requestor.new.request(:get, _url, params)
|
17
|
+
instance = ::Conekta::Operations::Where.handle_type_of_paging(response, self.class_name, params)
|
9
18
|
instance.load_from(response)
|
10
19
|
instance
|
11
20
|
end
|
@@ -18,4 +27,4 @@ module Conekta
|
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
21
|
-
end
|
30
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Conekta
|
2
|
+
class Order < Resource
|
3
|
+
include Conekta::Operations::Find
|
4
|
+
include Conekta::Operations::Where
|
5
|
+
include Conekta::Operations::Create
|
6
|
+
include Conekta::Operations::Update
|
7
|
+
include Conekta::Operations::CreateMember
|
8
|
+
include Conekta::Operations::CustomAction
|
9
|
+
|
10
|
+
attr_accessor :livemode, :amount, :status, :customer_id, :currency, :capture,
|
11
|
+
:metadata, :created_at, :updated_at, :tax_lines, :line_items,
|
12
|
+
:shipping_lines, :discount_lines, :shipping_contact, :fiscal_entity,
|
13
|
+
:charges, :returns
|
14
|
+
|
15
|
+
def initialize(id=nil)
|
16
|
+
@id = id
|
17
|
+
@line_items ||= List.new("LineItem", {})
|
18
|
+
@tax_lines ||= List.new("TaxLine", {})
|
19
|
+
@shipping_lines ||= List.new("ShippingLine", {})
|
20
|
+
@discount_lines ||= List.new("DiscountLine", {})
|
21
|
+
@charges ||= List.new("Charge", {})
|
22
|
+
@returns ||= List.new("Return", {})
|
23
|
+
super(id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_from(response = nil)
|
27
|
+
if response
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
order = self
|
32
|
+
submodels = [:line_items, :tax_lines, :shipping_lines, :discount_lines,
|
33
|
+
:charges, :returns]
|
34
|
+
create_submodels_lists(order, submodels)
|
35
|
+
|
36
|
+
if self.respond_to?(:fiscal_entity) && self.fiscal_entity
|
37
|
+
self.fiscal_entity.create_attr('order', order)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_line_item(params)
|
42
|
+
self.create_member('line_items', params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_tax_line(params)
|
46
|
+
self.create_member('tax_lines', params)
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_shipping_line(params)
|
50
|
+
self.create_member('shipping_lines', params)
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_discount_line(params)
|
54
|
+
self.create_member('discount_lines', params)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_charge(params)
|
58
|
+
self.create_member('charges', params)
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_return(params)
|
62
|
+
self.create_member('returns', params)
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_fiscal_entity(params)
|
66
|
+
self.update(fiscal_entity: params).fiscal_entity
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_shipping_contact(params)
|
70
|
+
self.update(shipping_contact: params).shipping_contact
|
71
|
+
end
|
72
|
+
|
73
|
+
def capture_order
|
74
|
+
custom_action(:put, 'capture')
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def create_submodels_lists(order, submodels)
|
80
|
+
submodels.each do |submodel|
|
81
|
+
self.send(submodel).each do |k, v|
|
82
|
+
v.create_attr('order', order)
|
83
|
+
|
84
|
+
self.send(submodel).set_val(k,v)
|
85
|
+
end if self.respond_to?(submodel) && !self.send(submodel).nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|