activeresource-zoho_invoice 0.0.2 → 0.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c14b2d4a27f6b0e6b41a769c1bc02c172e4ed5b
|
4
|
+
data.tar.gz: 7f084e3312c1e88dd6af54516961aefb0f062d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17826a918d136dc40c377a95013f669152a4cf9e61ad51dfbff5ab709881c7e92dc2870e383aaf81645f76b774e33e74c4d45ee4d4f0031bb84a6a088cddc0a7
|
7
|
+
data.tar.gz: 688837c1c220e90e064b7a0584fa2302ff1592000b6d3cd7bfbbcd0ca65f1c3d7777543af762f85a7088d318e15487d1e90cef3b2a035f6315e6dd355a9d47b8
|
@@ -36,6 +36,20 @@ module ZohoInvoiceResource
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
private
|
40
|
+
|
41
|
+
def remove_empty!(hash)
|
42
|
+
hash.each do |key, value|
|
43
|
+
case value
|
44
|
+
when Hash
|
45
|
+
remove_empty!(value)
|
46
|
+
when Array
|
47
|
+
value.compact!
|
48
|
+
end
|
49
|
+
hash.delete(key) if value.nil? || value == [] || value == {}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
39
53
|
def normalize_date(date)
|
40
54
|
if date.match %r|\d{4}/\d{2}/\d{2}|
|
41
55
|
date.tr('/', '-')
|
@@ -5,18 +5,42 @@ module ZohoInvoiceResource
|
|
5
5
|
options[:root] = options[:root].try(:camelize)
|
6
6
|
# updatable attributes restricted
|
7
7
|
data = {
|
8
|
-
'CustomerID'
|
9
|
-
'Name'
|
10
|
-
'PaymentsDue'
|
11
|
-
'BillingAddress'
|
12
|
-
'BillingCity'
|
13
|
-
'BillingState'
|
14
|
-
'BillingZip'
|
15
|
-
'BillingCountry'
|
16
|
-
'
|
17
|
-
|
8
|
+
'CustomerID' => record.customer_id,
|
9
|
+
'Name' => record.name,
|
10
|
+
'PaymentsDue' => record.payments_due,
|
11
|
+
'BillingAddress' => record.billing_address,
|
12
|
+
'BillingCity' => record.billing_city,
|
13
|
+
'BillingState' => record.billing_state,
|
14
|
+
'BillingZip' => record.billing_zip,
|
15
|
+
'BillingCountry' => record.billing_country,
|
16
|
+
'BillingFax' => record.billing_fax,
|
17
|
+
'ShippingAddress' => record.shipping_address,
|
18
|
+
'ShippingCity' => record.shipping_city,
|
19
|
+
'ShippingState' => record.shipping_state,
|
20
|
+
'ShippingZip' => record.shipping_zip,
|
21
|
+
'ShippingCountry' => record.shipping_country,
|
22
|
+
'ShippingFax' => record.shipping_fax,
|
23
|
+
'Contacts' => [],
|
24
|
+
'Notes' => record.notes,
|
25
|
+
'CustomFields' => {}
|
18
26
|
}
|
19
|
-
|
27
|
+
record.contacts.each do |contact|
|
28
|
+
item = {
|
29
|
+
'ContactID' => contact.contact_id,
|
30
|
+
'Salutation' => contact.salutation,
|
31
|
+
'FirstName' => contact.first_name,
|
32
|
+
'LastName' => contact.last_name,
|
33
|
+
'EMail' => contact.e_mail,
|
34
|
+
'Phone' => contact.phone,
|
35
|
+
'Mobile' => contact.mobile
|
36
|
+
}
|
37
|
+
data['Contacts'] << item
|
38
|
+
end if record.contacts
|
39
|
+
data['CustomFields']['CustomFieldValue1'] = record.custom_fields.custom_field_value1 if record.custom_fields.custom_field_label1
|
40
|
+
data['CustomFields']['CustomFieldValue2'] = record.custom_fields.custom_field_value2 if record.custom_fields.custom_field_label2
|
41
|
+
data['CustomFields']['CustomFieldValue3'] = record.custom_fields.custom_field_value3 if record.custom_fields.custom_field_label3
|
42
|
+
remove_empty!(data)
|
43
|
+
data.to_xml(options)
|
20
44
|
end
|
21
45
|
|
22
46
|
def decode(xml)
|
@@ -18,12 +18,11 @@ module ZohoInvoiceResource
|
|
18
18
|
'Price' => invoice_item.price
|
19
19
|
}
|
20
20
|
data['InvoiceItems'] << item
|
21
|
-
end
|
22
|
-
data.delete('InvoiceItems') if data['InvoiceItems'].empty?
|
21
|
+
end if record.invoice_items
|
23
22
|
data['CustomFields']['CustomField1'] = record.custom_fields.custom_field1 if record.custom_fields.custom_label1
|
24
23
|
data['CustomFields']['CustomField2'] = record.custom_fields.custom_field2 if record.custom_fields.custom_label2
|
25
24
|
data['CustomFields']['CustomField3'] = record.custom_fields.custom_field3 if record.custom_fields.custom_label3
|
26
|
-
data
|
25
|
+
remove_empty!(data)
|
27
26
|
data.to_xml(options)
|
28
27
|
end
|
29
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeresource-zoho_invoice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toru KAWAMURA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|