pagseguro-oficial 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.md +17 -1
- data/Gemfile +0 -2
- data/README.md +1 -1
- data/docs/transparent_checkout.md +3 -3
- data/examples/authorization/create_authorization.rb +32 -0
- data/examples/authorization/create_authorization_with_account.rb +56 -0
- data/examples/authorization/{authorization_by_code.rb → search/search_authorization_by_code.rb} +4 -4
- data/examples/authorization/search/search_authorization_by_date.rb +35 -0
- data/examples/authorization/{authorization_by_notification_code.rb → search/search_authorization_by_notification_code.rb} +4 -5
- data/examples/authorization/search/search_authorization_by_reference.rb +31 -0
- data/examples/{payment_request.rb → checkout/create_payment_request.rb} +5 -7
- data/examples/{transaction/abandoned_transactions.rb → checkout/search/search_abandoned_transactions.rb} +6 -3
- data/examples/{transaction/transaction_by_code.rb → checkout/search/search_transaction_by_code.rb} +3 -3
- data/examples/{transaction/transaction_by_notification_code.rb → checkout/search/search_transaction_by_notification_code.rb} +3 -3
- data/examples/{transaction/transaction_by_reference.rb → checkout/search/search_transaction_by_reference.rb} +3 -3
- data/examples/{transaction/transaction_status_history.rb → checkout/search/search_transaction_status_history.rb} +2 -2
- data/examples/{transaction/transactions_by_date.rb → checkout/search/search_transactions_by_date.rb} +3 -3
- data/examples/{transaction/boleto_transaction_request.rb → direct/create_transaction_using_boleto.rb} +1 -1
- data/examples/{transaction/credit_card_transaction_request.rb → direct/create_transaction_using_credit_card.rb} +1 -1
- data/examples/{transaction/online_debit_transaction.rb → direct/create_transaction_using_online_debit.rb} +1 -1
- data/examples/{installment.rb → get_installments.rb} +3 -3
- data/examples/{transaction/transaction_cancellation.rb → request_transaction_cancellation.rb} +2 -2
- data/examples/{authorization/authorization.rb → split_payment/create_authorization.rb} +5 -4
- data/examples/split_payment/create_payment_request.rb +71 -0
- data/lib/pagseguro.rb +14 -8
- data/lib/pagseguro/account.rb +29 -0
- data/lib/pagseguro/authorization.rb +10 -4
- data/lib/pagseguro/authorization/collection.rb +3 -1
- data/lib/pagseguro/authorization/request_serializer.rb +6 -6
- data/lib/pagseguro/authorization/response.rb +2 -2
- data/lib/pagseguro/authorization_request.rb +16 -4
- data/lib/pagseguro/authorization_request/request_serializer.rb +127 -15
- data/lib/pagseguro/authorization_request/response.rb +2 -2
- data/lib/pagseguro/company.rb +41 -0
- data/lib/pagseguro/document.rb +4 -0
- data/lib/pagseguro/documents.rb +5 -0
- data/lib/pagseguro/errors.rb +27 -5
- data/lib/pagseguro/extensions/collection_object.rb +34 -0
- data/lib/pagseguro/item.rb +4 -0
- data/lib/pagseguro/items.rb +10 -17
- data/lib/pagseguro/partner.rb +20 -0
- data/lib/pagseguro/payment_request.rb +30 -2
- data/lib/pagseguro/payment_request/{serializer.rb → request_serializer.rb} +86 -1
- data/lib/pagseguro/person.rb +40 -0
- data/lib/pagseguro/phone.rb +8 -0
- data/lib/pagseguro/phones.rb +5 -0
- data/lib/pagseguro/receiver.rb +17 -0
- data/lib/pagseguro/receiver_split.rb +15 -0
- data/lib/pagseguro/request.rb +25 -1
- data/lib/pagseguro/transaction.rb +7 -5
- data/lib/pagseguro/transaction_cancellation.rb +3 -6
- data/lib/pagseguro/transaction_cancellation/response.rb +7 -6
- data/lib/pagseguro/{refund.rb → transaction_refund.rb} +2 -2
- data/lib/pagseguro/{refund → transaction_refund}/request_serializer.rb +1 -1
- data/lib/pagseguro/{refund → transaction_refund}/response.rb +9 -9
- data/lib/pagseguro/{refund → transaction_refund}/response_serializer.rb +1 -1
- data/lib/pagseguro/transaction_request.rb +1 -4
- data/lib/pagseguro/transaction_request/response.rb +8 -7
- data/lib/pagseguro/version.rb +1 -1
- data/locales/pt-BR.yml +1 -0
- data/pagseguro-oficial.gemspec +13 -13
- data/spec/fixtures/authorization/search_authorization.xml +47 -0
- data/spec/fixtures/authorization_request/authorization_request.xml +11 -0
- data/spec/fixtures/authorization_request/authorization_request_with_account.xml +47 -0
- data/spec/pagseguro/account_spec.rb +27 -0
- data/spec/pagseguro/authorization/collection_spec.rb +3 -3
- data/spec/pagseguro/authorization/request_serializer_spec.rb +1 -2
- data/spec/pagseguro/authorization/response_spec.rb +70 -15
- data/spec/pagseguro/authorization_request/request_serializer_spec.rb +314 -14
- data/spec/pagseguro/authorization_request_spec.rb +96 -31
- data/spec/pagseguro/authorization_spec.rb +52 -10
- data/spec/pagseguro/company_spec.rb +12 -0
- data/spec/pagseguro/documents_spec.rb +37 -0
- data/spec/pagseguro/errors_spec.rb +45 -6
- data/spec/pagseguro/extensions/collection_object_spec.rb +77 -0
- data/spec/pagseguro/features/create_transaction_request_spec.rb +2 -2
- data/spec/pagseguro/installment/response_spec.rb +5 -3
- data/spec/pagseguro/installment_spec.rb +5 -2
- data/spec/pagseguro/items_spec.rb +104 -12
- data/spec/pagseguro/pagseguro_spec.rb +8 -8
- data/spec/pagseguro/partner_spec.rb +8 -0
- data/spec/pagseguro/payment_request/request_serializer_spec.rb +251 -0
- data/spec/pagseguro/payment_request_spec.rb +67 -11
- data/spec/pagseguro/person_spec.rb +10 -0
- data/spec/pagseguro/phones_spec.rb +38 -0
- data/spec/pagseguro/receiver_spec.rb +6 -0
- data/spec/pagseguro/receiver_split_spec.rb +7 -0
- data/spec/pagseguro/request_spec.rb +27 -4
- data/spec/pagseguro/session/response_spec.rb +6 -2
- data/spec/pagseguro/session_spec.rb +5 -2
- data/spec/pagseguro/transaction/response_spec.rb +14 -8
- data/spec/pagseguro/transaction/search_spec.rb +15 -8
- data/spec/pagseguro/transaction_cancellation/response_spec.rb +6 -3
- data/spec/pagseguro/transaction_cancellation_spec.rb +7 -5
- data/spec/pagseguro/{refund → transaction_refund}/request_serializer_spec.rb +3 -3
- data/spec/pagseguro/{refund → transaction_refund}/response_serializer_spec.rb +1 -1
- data/spec/pagseguro/{refund → transaction_refund}/response_spec.rb +3 -3
- data/spec/pagseguro/{refund_spec.rb → transaction_refund_spec.rb} +15 -7
- data/spec/pagseguro/transaction_request/request_serializer_spec.rb +9 -9
- data/spec/pagseguro/transaction_request/response_spec.rb +5 -2
- data/spec/pagseguro/transaction_request_spec.rb +14 -9
- data/spec/pagseguro/transaction_spec.rb +37 -30
- data/spec/spec_helper.rb +0 -3
- data/spec/support/ensure_type_macro.rb +20 -2
- data/{examples/refund.rb → transaction/transaction_refund.rb} +1 -1
- metadata +112 -96
- data/examples/transaction/invalid_transaction_by_notification_code.rb +0 -22
- data/lib/pagseguro/refund/serializer.rb +0 -24
- data/lib/pagseguro/transaction_cancellation/serializer.rb +0 -18
- data/spec/pagseguro/payment_request/serializer_spec.rb +0 -166
- data/spec/pagseguro/refund/serializer_spec.rb +0 -15
- data/spec/pagseguro/transaction_cancellation/serializer_spec.rb +0 -13
@@ -6,7 +6,7 @@ module PagSeguro
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def serialize
|
9
|
-
if
|
9
|
+
if success?
|
10
10
|
xml = Nokogiri::XML(response.body).css('authorizationRequest').first
|
11
11
|
ResponseSerializer.new(xml).serialize
|
12
12
|
else
|
@@ -15,7 +15,7 @@ module PagSeguro
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def success?
|
18
|
-
|
18
|
+
response.success? && response.xml?
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module PagSeguro
|
2
|
+
class Company
|
3
|
+
include Extensions::MassAssignment
|
4
|
+
include Extensions::EnsureType
|
5
|
+
|
6
|
+
attr_accessor :name
|
7
|
+
attr_accessor :display_name
|
8
|
+
attr_accessor :website_url
|
9
|
+
|
10
|
+
attr_reader :address
|
11
|
+
attr_reader :partner
|
12
|
+
|
13
|
+
def address=(address)
|
14
|
+
@address = ensure_type(Address, address)
|
15
|
+
end
|
16
|
+
|
17
|
+
def partner=(partner)
|
18
|
+
@partner = ensure_type(Partner, partner)
|
19
|
+
end
|
20
|
+
|
21
|
+
def phones
|
22
|
+
@phones ||= Phones.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def phones=(_phones=[])
|
26
|
+
_phones.each do |phone|
|
27
|
+
phones << ensure_type(Phone, phone)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def documents
|
32
|
+
@documents ||= Documents.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def documents=(_documents=[])
|
36
|
+
_documents.each do |document|
|
37
|
+
documents << ensure_type(Document, document)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/pagseguro/document.rb
CHANGED
data/lib/pagseguro/errors.rb
CHANGED
@@ -20,16 +20,38 @@ module PagSeguro
|
|
20
20
|
|
21
21
|
private
|
22
22
|
def process(response)
|
23
|
-
|
24
|
-
@messages << error_message(
|
23
|
+
return unless response.error?
|
24
|
+
@messages << error_message(
|
25
|
+
error_to_sym(response.error),
|
26
|
+
error_to_human(response.error)
|
27
|
+
)
|
25
28
|
|
26
|
-
response.
|
27
|
-
|
28
|
-
|
29
|
+
if response.error == Aitch::BadRequestError
|
30
|
+
response.data.css("errors > error").each do |error|
|
31
|
+
@messages << error_message(error.css("code").text, error.css("message").text)
|
32
|
+
end
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
def error_message(code, message)
|
32
37
|
I18n.t(code, scope: "pagseguro.errors", default: message)
|
33
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
# Error formats
|
42
|
+
def error_to_sym(error)
|
43
|
+
error.to_s.split(/::/)[-1]
|
44
|
+
.gsub(/Error$/, '')
|
45
|
+
.gsub(/[[:upper:]]/)
|
46
|
+
.with_index {|k, i| i == 0 ? k : ('_' + k)}
|
47
|
+
.downcase
|
48
|
+
.to_sym
|
49
|
+
end
|
50
|
+
|
51
|
+
def error_to_human(error)
|
52
|
+
error_to_sym(error).to_s
|
53
|
+
.capitalize
|
54
|
+
.gsub('_', ' ')
|
55
|
+
end
|
34
56
|
end
|
35
57
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module PagSeguro
|
2
|
+
module Extensions
|
3
|
+
module CollectionObject
|
4
|
+
extend Forwardable
|
5
|
+
include Enumerable
|
6
|
+
include EnsureType
|
7
|
+
|
8
|
+
def_delegators :@store, :size, :clear, :empty?, :any?, :each, :include?
|
9
|
+
|
10
|
+
attr_accessor :store
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@store = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def collection_type
|
17
|
+
PagSeguro.const_get(class_name_singularized)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Adds a new object to the collection.
|
21
|
+
def <<(param)
|
22
|
+
object = ensure_type(collection_type, param)
|
23
|
+
@store << object unless include?(object)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def class_name_singularized
|
29
|
+
class_name = self.class.to_s.split('::').last
|
30
|
+
class_name[0...-1] if class_name.end_with? 's'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/pagseguro/item.rb
CHANGED
data/lib/pagseguro/items.rb
CHANGED
@@ -1,30 +1,23 @@
|
|
1
1
|
module PagSeguro
|
2
2
|
class Items
|
3
|
-
|
4
|
-
include Enumerable
|
5
|
-
include Extensions::EnsureType
|
3
|
+
include Extensions::CollectionObject
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@store = []
|
11
|
-
end
|
12
|
-
|
13
|
-
# Adds a new item to item list.
|
5
|
+
# Overriding standard method to add new objects
|
14
6
|
def <<(item)
|
15
7
|
item = ensure_type(Item, item)
|
16
8
|
|
17
|
-
|
18
|
-
|
9
|
+
original_item = find_item(item)
|
10
|
+
|
11
|
+
if original_item
|
12
|
+
original_item.quantity += (item.quantity || 1)
|
19
13
|
else
|
20
|
-
|
14
|
+
store << item
|
21
15
|
end
|
22
16
|
end
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@store.find {|stored_item| stored_item.id == ensure_type(Item, item).id }
|
18
|
+
private
|
19
|
+
def find_item(item)
|
20
|
+
store.detect {|stored_item| stored_item == item }
|
28
21
|
end
|
29
22
|
end
|
30
23
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PagSeguro
|
2
|
+
class Partner
|
3
|
+
include Extensions::MassAssignment
|
4
|
+
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
# Pattern: aaaa-MM-dd
|
8
|
+
attr_accessor :birth_date
|
9
|
+
|
10
|
+
def documents
|
11
|
+
@documents ||= Documents.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def documents=(_documents=[])
|
15
|
+
_documents.each do |document|
|
16
|
+
documents << document
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -11,6 +11,12 @@ module PagSeguro
|
|
11
11
|
# Get the payment sender.
|
12
12
|
attr_reader :sender
|
13
13
|
|
14
|
+
# Set and get primary receiver email.
|
15
|
+
attr_accessor :primary_receiver
|
16
|
+
|
17
|
+
# Get the payment receivers.
|
18
|
+
attr_reader :receivers
|
19
|
+
|
14
20
|
# Get the shipping info.
|
15
21
|
attr_reader :shipping
|
16
22
|
|
@@ -65,6 +71,13 @@ module PagSeguro
|
|
65
71
|
@sender = ensure_type(Sender, sender)
|
66
72
|
end
|
67
73
|
|
74
|
+
# Set the receivers.
|
75
|
+
def receivers=(receivers)
|
76
|
+
receivers.each do |receiver|
|
77
|
+
@receivers << ensure_type(Receiver, receiver)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
68
81
|
# Set the shipping info.
|
69
82
|
def shipping=(shipping)
|
70
83
|
@shipping = ensure_type(Shipping, shipping)
|
@@ -72,14 +85,29 @@ module PagSeguro
|
|
72
85
|
|
73
86
|
# Calls the PagSeguro web service and register this request for payment.
|
74
87
|
def register
|
75
|
-
|
76
|
-
|
88
|
+
request = if @receivers.empty?
|
89
|
+
Request.post('checkout', api_version, params)
|
90
|
+
else
|
91
|
+
Request.post_xml('checkouts', api_version, credentials, xml_params)
|
92
|
+
end
|
93
|
+
|
94
|
+
Response.new(request)
|
77
95
|
end
|
78
96
|
|
79
97
|
private
|
98
|
+
|
99
|
+
def xml_params
|
100
|
+
RequestSerializer.new(self).to_xml_params
|
101
|
+
end
|
102
|
+
|
103
|
+
def params
|
104
|
+
RequestSerializer.new(self).to_params
|
105
|
+
end
|
106
|
+
|
80
107
|
def before_initialize
|
81
108
|
self.extra_params = []
|
82
109
|
self.currency = "BRL"
|
110
|
+
@receivers = []
|
83
111
|
end
|
84
112
|
|
85
113
|
def api_version
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module PagSeguro
|
2
2
|
class PaymentRequest
|
3
|
-
class
|
3
|
+
class RequestSerializer
|
4
4
|
# The payment request that will be serialized.
|
5
5
|
attr_reader :payment_request
|
6
6
|
|
@@ -8,6 +8,14 @@ module PagSeguro
|
|
8
8
|
@payment_request = payment_request
|
9
9
|
end
|
10
10
|
|
11
|
+
def to_xml_params
|
12
|
+
xml_builder.to_xml(
|
13
|
+
save_with:
|
14
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
15
|
+
Nokogiri::XML::Node::SaveOptions::FORMAT
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
11
19
|
def to_params
|
12
20
|
{}.tap do |data|
|
13
21
|
data[:receiverEmail] = PagSeguro.receiver_email
|
@@ -19,17 +27,33 @@ module PagSeguro
|
|
19
27
|
data[:abandonURL] = payment_request.abandon_url
|
20
28
|
data[:maxUses] = payment_request.max_uses
|
21
29
|
data[:maxAge] = payment_request.max_age
|
30
|
+
data[:credentials] = payment_request.credentials
|
22
31
|
payment_request.items.each_with_index do |item, index|
|
23
32
|
serialize_item(data, item, index.succ)
|
24
33
|
end
|
25
34
|
|
26
35
|
serialize_sender(data, payment_request.sender)
|
27
36
|
serialize_shipping(data, payment_request.shipping)
|
37
|
+
serialize_receivers(data, payment_request.receivers)
|
28
38
|
serialize_extra_params(data, payment_request.extra_params)
|
29
39
|
end.delete_if { |_, value| value.nil? }
|
30
40
|
end
|
31
41
|
|
32
42
|
private
|
43
|
+
|
44
|
+
def serialize_receivers(data, receivers)
|
45
|
+
receivers.each.with_index(1) do |receiver, idx|
|
46
|
+
data["receiver[#{idx}].email"] = receiver.email
|
47
|
+
serialize_receiver_split(data, receiver, idx, receiver.split)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def serialize_receiver_split(data, receiver, idx, split)
|
52
|
+
data["receiver[#{idx}].split.amount"] = receiver.split.amount
|
53
|
+
data["receiver[#{idx}].split.feePercent"] = receiver.split.fee_percent
|
54
|
+
data["receiver[#{idx}].split.ratePercent"] = receiver.split.rate_percent
|
55
|
+
end
|
56
|
+
|
33
57
|
def serialize_item(data, item, index)
|
34
58
|
data["itemId#{index}"] = item.id
|
35
59
|
data["itemDescription#{index}"] = item.description
|
@@ -89,6 +113,67 @@ module PagSeguro
|
|
89
113
|
def to_amount(amount)
|
90
114
|
"%.2f" % BigDecimal(amount.to_s).round(2).to_s("F") if amount
|
91
115
|
end
|
116
|
+
|
117
|
+
def xml_builder
|
118
|
+
Nokogiri::XML::Builder.new(encoding: PagSeguro.encoding) do |xml|
|
119
|
+
xml.send(:checkout) {
|
120
|
+
xml_serialize_receivers(xml)
|
121
|
+
xml_serialize_sender(xml, payment_request.sender)
|
122
|
+
xml.send(:currency, payment_request.currency)
|
123
|
+
xml.send(:reference, payment_request.reference)
|
124
|
+
xml.send(:redirectURL, payment_request.redirect_url)
|
125
|
+
xml.send(:notificationURL, payment_request.notification_url)
|
126
|
+
xml_serialize_items(xml, payment_request.items)
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def xml_serialize_items(xml, items)
|
132
|
+
xml.send(:items) {
|
133
|
+
items.each do |item|
|
134
|
+
xml.send(:item) {
|
135
|
+
xml.send(:id, item.id)
|
136
|
+
xml.send(:description, item.description)
|
137
|
+
xml.send(:quantity, item.quantity)
|
138
|
+
xml.send(:amount, to_amount(item.amount))
|
139
|
+
xml.send(:weight, item.weight) if item.weight
|
140
|
+
xml.send(:shippingCost, to_amount(item.shipping_cost))
|
141
|
+
}
|
142
|
+
end
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
def xml_serialize_sender(xml, sender)
|
147
|
+
return unless sender
|
148
|
+
|
149
|
+
xml.send(:sender) {
|
150
|
+
xml.send(:name, sender.name)
|
151
|
+
xml.send(:email, sender.email)
|
152
|
+
if sender.phone
|
153
|
+
xml.send(:phone) {
|
154
|
+
xml.send(:areaCode, sender.phone.area_code)
|
155
|
+
xml.send(:number, sender.phone.number)
|
156
|
+
}
|
157
|
+
end
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
def xml_serialize_receivers(xml)
|
162
|
+
xml.send(:primaryReceiver) {
|
163
|
+
xml.send(:email, payment_request.primary_receiver)
|
164
|
+
}
|
165
|
+
|
166
|
+
xml.send(:receivers) {
|
167
|
+
payment_request.receivers.each do |receiver|
|
168
|
+
xml.send(:receiver) {
|
169
|
+
xml.send(:email, receiver.email)
|
170
|
+
xml.send(:split) {
|
171
|
+
xml.send(:amount, receiver.split.amount)
|
172
|
+
}
|
173
|
+
}
|
174
|
+
end
|
175
|
+
}
|
176
|
+
end
|
92
177
|
end
|
93
178
|
end
|
94
179
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module PagSeguro
|
2
|
+
class Person
|
3
|
+
include Extensions::MassAssignment
|
4
|
+
include Extensions::EnsureType
|
5
|
+
|
6
|
+
# Set the account name.
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
# Set the account birth_date.
|
10
|
+
# Pattern: aaaa-MM-dd
|
11
|
+
attr_accessor :birth_date
|
12
|
+
|
13
|
+
# Set the account address.
|
14
|
+
attr_reader :address
|
15
|
+
|
16
|
+
def address=(address)
|
17
|
+
@address = ensure_type(Address, address)
|
18
|
+
end
|
19
|
+
|
20
|
+
def documents
|
21
|
+
@documents ||= Documents.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def documents=(_documents=[])
|
25
|
+
_documents.each do |document|
|
26
|
+
documents << ensure_type(Document, document)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def phones
|
31
|
+
@phones ||= Phones.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def phones=(_phones=[])
|
35
|
+
_phones.each do |phone|
|
36
|
+
phones << ensure_type(Phone, phone)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|