netsuite 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +132 -54
- data/lib/netsuite.rb +123 -76
- data/lib/netsuite/actions/add.rb +1 -0
- data/lib/netsuite/actions/delete.rb +1 -0
- data/lib/netsuite/actions/get.rb +1 -0
- data/lib/netsuite/actions/get_all.rb +67 -0
- data/lib/netsuite/actions/get_list.rb +2 -1
- data/lib/netsuite/actions/get_select_value.rb +1 -0
- data/lib/netsuite/actions/initialize.rb +1 -0
- data/lib/netsuite/actions/login.rb +2 -0
- data/lib/netsuite/actions/search.rb +3 -2
- data/lib/netsuite/actions/update.rb +18 -0
- data/lib/netsuite/actions/upsert.rb +1 -0
- data/lib/netsuite/actions/upsert_list.rb +114 -0
- data/lib/netsuite/configuration.rb +5 -0
- data/lib/netsuite/namespaces/file_cabinet.rb +11 -0
- data/lib/netsuite/namespaces/list_emp.rb +12 -0
- data/lib/netsuite/namespaces/list_mkt.rb +12 -0
- data/lib/netsuite/namespaces/list_website.rb +11 -0
- data/lib/netsuite/namespaces/tran_invt.rb +11 -0
- data/lib/netsuite/records/accounting_period.rb +1 -1
- data/lib/netsuite/records/assembly_item.rb +10 -4
- data/lib/netsuite/records/billing_schedule.rb +33 -0
- data/lib/netsuite/records/billing_schedule_milestone.rb +28 -0
- data/lib/netsuite/records/billing_schedule_milestone_list.rb +33 -0
- data/lib/netsuite/records/billing_schedule_recurrence.rb +28 -0
- data/lib/netsuite/records/billing_schedule_recurrence_list.rb +33 -0
- data/lib/netsuite/records/bin.rb +22 -0
- data/lib/netsuite/records/campaign.rb +28 -0
- data/lib/netsuite/records/cash_refund.rb +1 -1
- data/lib/netsuite/records/classification.rb +1 -1
- data/lib/netsuite/records/contact.rb +1 -1
- data/lib/netsuite/records/contact_access_roles.rb +14 -0
- data/lib/netsuite/records/contact_access_roles_list.rb +9 -0
- data/lib/netsuite/records/custom_field.rb +2 -1
- data/lib/netsuite/records/custom_field_list.rb +23 -4
- data/lib/netsuite/records/custom_list.rb +27 -0
- data/lib/netsuite/records/custom_list_custom_value.rb +14 -0
- data/lib/netsuite/records/custom_list_custom_value_list.rb +13 -0
- data/lib/netsuite/records/custom_record.rb +1 -1
- data/lib/netsuite/records/custom_record_type.rb +1 -1
- data/lib/netsuite/records/customer.rb +4 -4
- data/lib/netsuite/records/customer_addressbook.rb +8 -5
- data/lib/netsuite/records/customer_addressbook_list.rb +13 -1
- data/lib/netsuite/records/customer_deposit.rb +3 -2
- data/lib/netsuite/records/customer_payment.rb +1 -1
- data/lib/netsuite/records/customer_refund.rb +1 -1
- data/lib/netsuite/records/department.rb +4 -2
- data/lib/netsuite/records/deposit.rb +1 -1
- data/lib/netsuite/records/deposit_cash_back.rb +2 -2
- data/lib/netsuite/records/deposit_other.rb +2 -2
- data/lib/netsuite/records/discount_item.rb +32 -0
- data/lib/netsuite/records/employee.rb +20 -0
- data/lib/netsuite/records/file.rb +28 -0
- data/lib/netsuite/records/inventory_assignment.rb +24 -0
- data/lib/netsuite/records/inventory_assignment_list.rb +32 -0
- data/lib/netsuite/records/inventory_detail.rb +18 -0
- data/lib/netsuite/records/inventory_transfer.rb +29 -0
- data/lib/netsuite/records/inventory_transfer_inventory.rb +21 -0
- data/lib/netsuite/records/inventory_transfer_inventory_list.rb +33 -0
- data/lib/netsuite/records/item_fulfillment.rb +1 -1
- data/lib/netsuite/records/item_fulfillment_item_list.rb +3 -21
- data/lib/netsuite/records/item_member.rb +21 -0
- data/lib/netsuite/records/journal_entry.rb +1 -1
- data/lib/netsuite/records/kit_item.rb +1 -1
- data/lib/netsuite/records/location.rb +3 -1
- data/lib/netsuite/records/member_list.rb +32 -0
- data/lib/netsuite/records/non_inventory_sale_item.rb +4 -1
- data/lib/netsuite/records/partner.rb +21 -0
- data/lib/netsuite/records/promotion_code.rb +38 -0
- data/lib/netsuite/records/record_ref_list.rb +40 -0
- data/lib/netsuite/records/role_list.rb +25 -0
- data/lib/netsuite/records/sales_order.rb +6 -2
- data/lib/netsuite/records/sales_tax_item.rb +32 -0
- data/lib/netsuite/records/site_category.rb +33 -0
- data/lib/netsuite/records/subsidiary.rb +38 -0
- data/lib/netsuite/records/tax_type.rb +22 -0
- data/lib/netsuite/records/term.rb +1 -1
- data/lib/netsuite/records/units_type.rb +25 -0
- data/lib/netsuite/records/units_type_uom.rb +20 -0
- data/lib/netsuite/records/units_type_uom_list.rb +33 -0
- data/lib/netsuite/records/work_order.rb +38 -0
- data/lib/netsuite/records/work_order_item.rb +31 -0
- data/lib/netsuite/records/work_order_item_list.rb +31 -0
- data/lib/netsuite/support/actions.rb +4 -0
- data/lib/netsuite/support/base.rb +21 -0
- data/lib/netsuite/support/country.rb +273 -0
- data/lib/netsuite/support/search_result.rb +4 -0
- data/lib/netsuite/support/sublist.rb +54 -0
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/actions/search_spec.rb +1 -1
- data/spec/netsuite/actions/update_spec.rb +62 -31
- data/spec/netsuite/actions/upsert_list_spec.rb +112 -0
- data/spec/netsuite/records/account_spec.rb +4 -4
- data/spec/netsuite/records/accounting_period_spec.rb +4 -4
- data/spec/netsuite/records/assembly_item_spec.rb +38 -0
- data/spec/netsuite/records/billing_schedule_milestone_list_spec.rb +24 -0
- data/spec/netsuite/records/billing_schedule_milestone_spec.rb +51 -0
- data/spec/netsuite/records/billing_schedule_recurrence_list_spec.rb +24 -0
- data/spec/netsuite/records/billing_schedule_recurrence_spec.rb +49 -0
- data/spec/netsuite/records/billing_schedule_spec.rb +164 -0
- data/spec/netsuite/records/campaign_spec.rb +43 -0
- data/spec/netsuite/records/cash_refund_spec.rb +1 -1
- data/spec/netsuite/records/classification_spec.rb +2 -2
- data/spec/netsuite/records/credit_memo_spec.rb +4 -4
- data/spec/netsuite/records/custom_field_list_spec.rb +10 -0
- data/spec/netsuite/records/custom_list_spec.rb +21 -0
- data/spec/netsuite/records/custom_record_spec.rb +5 -5
- data/spec/netsuite/records/custom_record_type_spec.rb +5 -5
- data/spec/netsuite/records/customer_addressbook_list_spec.rb +19 -1
- data/spec/netsuite/records/customer_addressbook_spec.rb +42 -13
- data/spec/netsuite/records/customer_payment_spec.rb +4 -4
- data/spec/netsuite/records/customer_refund_spec.rb +4 -4
- data/spec/netsuite/records/customer_spec.rb +80 -6
- data/spec/netsuite/records/department_spec.rb +4 -4
- data/spec/netsuite/records/deposit_spec.rb +22 -4
- data/spec/netsuite/records/discount_item_spec.rb +124 -0
- data/spec/netsuite/records/inventory_item_spec.rb +4 -4
- data/spec/netsuite/records/inventory_transfer_spec.rb +58 -0
- data/spec/netsuite/records/invoice_spec.rb +4 -4
- data/spec/netsuite/records/job_spec.rb +7 -7
- data/spec/netsuite/records/journal_entry_spec.rb +5 -5
- data/spec/netsuite/records/non_inventory_sale_item_spec.rb +4 -4
- data/spec/netsuite/records/payment_method_spec.rb +1 -1
- data/spec/netsuite/records/pomo_code_spec.rb +40 -0
- data/spec/netsuite/records/sales_order_spec.rb +18 -18
- data/spec/netsuite/records/sales_tax_item_spec.rb +30 -0
- data/spec/netsuite/records/service_sale_item_spec.rb +4 -4
- data/spec/netsuite/records/site_category_spec.rb +51 -0
- data/spec/netsuite/records/subsidiary_spec.rb +25 -0
- data/spec/netsuite/records/support_case_spec.rb +8 -8
- data/spec/netsuite/records/tax_type_spec.rb +11 -0
- data/spec/netsuite/records/term_spec.rb +4 -4
- data/spec/netsuite/records/units_type_spec.rb +33 -0
- data/spec/netsuite/records/units_type_uom_list_spec.rb +23 -0
- data/spec/netsuite/records/units_type_uom_spec.rb +14 -0
- data/spec/netsuite/records/work_order_item_list_spec.rb +26 -0
- data/spec/netsuite/records/work_order_item_spec.rb +45 -0
- data/spec/netsuite/records/work_order_spec.rb +92 -0
- data/spec/netsuite/support/record_refs_spec.rb +1 -1
- data/spec/netsuite/support/sublist_spec.rb +36 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixtures/update/update_customer_error.xml +21 -0
- data/spec/support/fixtures/update/update_customer_multiple_errors.xml +25 -0
- data/spec/support/fixtures/upsert_list/upsert_list_customers.xml +21 -0
- data/spec/support/fixtures/upsert_list/upsert_list_one_customer.xml +17 -0
- data/spec/support/fixtures/upsert_list/upsert_list_with_errors.xml +32 -0
- data/spec/support/read_only_field_matcher.rb +1 -1
- metadata +115 -5
- checksums.yaml +0 -15
@@ -0,0 +1,38 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class WorkOrder
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Support::Actions
|
8
|
+
include Namespaces::TranInvt
|
9
|
+
|
10
|
+
actions :get, :add, :initialize, :delete, :update, :upsert, :upsert_list,
|
11
|
+
:search
|
12
|
+
|
13
|
+
fields :buildable, :built, :created_date, :end_date, :expanded_assembly,
|
14
|
+
:firmed, :is_wip, :last_modified_date, :memo, :order_status,
|
15
|
+
:partners_list, :quantity, :sales_team_list, :source_transaction_id,
|
16
|
+
:source_transaction_line, :special_order, :start_date, :status,
|
17
|
+
:tran_date, :tran_id
|
18
|
+
|
19
|
+
field :custom_field_list, CustomFieldList
|
20
|
+
field :options, CustomFieldList
|
21
|
+
field :item_list, WorkOrderItemList
|
22
|
+
|
23
|
+
record_refs :assembly_item, :created_from, :custom_form,
|
24
|
+
:department, :entity, :job, :location, :manufacturing_routing,
|
25
|
+
:revision, :subsidiary, :units
|
26
|
+
|
27
|
+
attr_reader :internal_id
|
28
|
+
attr_accessor :external_id
|
29
|
+
attr_accessor :search_joins
|
30
|
+
|
31
|
+
def initialize(attributes = {})
|
32
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
33
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
34
|
+
initialize_from_attributes_hash(attributes)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class WorkOrderItem
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Namespaces::TranInvt
|
8
|
+
|
9
|
+
fields :average_cost, :bom_quantity, :commit, :component_yield,
|
10
|
+
:contribution, :create_po, :create_wo, :description, :inventory_detail,
|
11
|
+
:last_purchase_price, :line, :order_priority, :percent_complete,
|
12
|
+
:po_rate, :quantity, :quantity_available, :quantity_back_ordered,
|
13
|
+
:quantity_committed, :quantity_on_hand, :serial_numbers
|
14
|
+
|
15
|
+
field :custom_field_list, CustomFieldList
|
16
|
+
field :options, CustomFieldList
|
17
|
+
|
18
|
+
record_refs :department, :item, :location, :po_vender, :units
|
19
|
+
|
20
|
+
attr_reader :internal_id
|
21
|
+
attr_accessor :external_id
|
22
|
+
attr_accessor :search_joins
|
23
|
+
|
24
|
+
def initialize(attributes = {})
|
25
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
26
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
27
|
+
initialize_from_attributes_hash(attributes)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class WorkOrderItemList
|
4
|
+
include Support::Fields
|
5
|
+
include Namespaces::TranInvt
|
6
|
+
|
7
|
+
fields :item
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
initialize_from_attributes_hash(attributes)
|
11
|
+
end
|
12
|
+
|
13
|
+
def item=(items)
|
14
|
+
case items
|
15
|
+
when Hash
|
16
|
+
self.items << WorkOrderItem.new(items)
|
17
|
+
when Array
|
18
|
+
items.each { |item| self.items << WorkOrderItem.new(item) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def items
|
23
|
+
@items ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_record
|
27
|
+
{ "#{record_namespace}:item" => items.map(&:to_record) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -20,6 +20,8 @@ module NetSuite
|
|
20
20
|
case name
|
21
21
|
when :get
|
22
22
|
self.send(:include, NetSuite::Actions::Get::Support)
|
23
|
+
when :get_all
|
24
|
+
self.send(:include, NetSuite::Actions::GetAll::Support)
|
23
25
|
when :get_list
|
24
26
|
self.send(:include, NetSuite::Actions::GetList::Support)
|
25
27
|
when :get_select_value
|
@@ -32,6 +34,8 @@ module NetSuite
|
|
32
34
|
self.send(:include, NetSuite::Actions::Add::Support)
|
33
35
|
when :upsert
|
34
36
|
self.send(:include, NetSuite::Actions::Upsert::Support)
|
37
|
+
when :upsert_list
|
38
|
+
self.send(:include, NetSuite::Actions::UpsertList::Support)
|
35
39
|
when :delete
|
36
40
|
self.send(:include, NetSuite::Actions::Delete::Support)
|
37
41
|
when :update
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# https://github.com/NetSweet/netsuite/pull/129#discussion_r19126261
|
2
|
+
|
3
|
+
module NetSuite
|
4
|
+
module Support
|
5
|
+
|
6
|
+
class Base
|
7
|
+
include Support::Records
|
8
|
+
include Support::Fields
|
9
|
+
|
10
|
+
def initialize(attributes = {})
|
11
|
+
# not all records have external/internal ID
|
12
|
+
# we extract them here, but it's up to the subclass to create the accessors
|
13
|
+
|
14
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
15
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
16
|
+
initialize_from_attributes_hash(attributes)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Support
|
3
|
+
class Country
|
4
|
+
|
5
|
+
ISO_TO_NETSUITE = {
|
6
|
+
'AF' => '_afghanistan',
|
7
|
+
'AL' => '_albania',
|
8
|
+
'DZ' => '_algeria',
|
9
|
+
'AS' => '_americanSamoa',
|
10
|
+
'AD' => '_andorra',
|
11
|
+
'AO' => '_angola',
|
12
|
+
'AI' => '_anguilla',
|
13
|
+
'AQ' => '_antarctica',
|
14
|
+
'AG' => '_antiguaAndBarbuda',
|
15
|
+
'AR' => '_argentina',
|
16
|
+
'AM' => '_armenia',
|
17
|
+
'AW' => '_aruba',
|
18
|
+
'AU' => '_australia',
|
19
|
+
'AT' => '_austria',
|
20
|
+
'AZ' => '_azerbaijan',
|
21
|
+
'BS' => '_bahamas',
|
22
|
+
'BH' => '_bahrain',
|
23
|
+
'BD' => '_bangladesh',
|
24
|
+
'BB' => '_barbados',
|
25
|
+
'BY' => '_belarus',
|
26
|
+
'BE' => '_belgium',
|
27
|
+
'BZ' => '_belize',
|
28
|
+
'BJ' => '_benin',
|
29
|
+
'BM' => '_bermuda',
|
30
|
+
'BT' => '_bhutan',
|
31
|
+
'BO' => '_bolivia',
|
32
|
+
'BA' => '_bosniaAndHerzegovina',
|
33
|
+
'BW' => '_botswana',
|
34
|
+
'BV' => '_bouvetIsland',
|
35
|
+
'BR' => '_brazil',
|
36
|
+
'IO' => '_britishIndianOceanTerritory',
|
37
|
+
'BN' => '_bruneiDarussalam',
|
38
|
+
'BG' => '_bulgaria',
|
39
|
+
'BF' => '_burkinaFaso',
|
40
|
+
'BI' => '_burundi',
|
41
|
+
'KH' => '_cambodia',
|
42
|
+
'CM' => '_cameroon',
|
43
|
+
'CA' => '_canada',
|
44
|
+
'CV' => '_capVerde',
|
45
|
+
'KY' => '_caymanIslands',
|
46
|
+
'CF' => '_centralAfricanRepublic',
|
47
|
+
'TD' => '_chad',
|
48
|
+
'CL' => '_chile',
|
49
|
+
'CN' => '_china',
|
50
|
+
'CX' => '_christmasIsland',
|
51
|
+
'CC' => '_cocosKeelingIslands',
|
52
|
+
'CO' => '_colombia',
|
53
|
+
'KM' => '_comoros',
|
54
|
+
'CD' => '_congoDemocraticPeoplesRepublic',
|
55
|
+
'CG' => '_congoRepublicOf',
|
56
|
+
'CK' => '_cookIslands',
|
57
|
+
'CR' => '_costaRica',
|
58
|
+
'CI' => '_coteDIvoire',
|
59
|
+
'HR' => '_croatiaHrvatska',
|
60
|
+
'CU' => '_cuba',
|
61
|
+
'CW' => '_curacao',
|
62
|
+
'CY' => '_cyprus',
|
63
|
+
'CZ' => '_czechRepublic',
|
64
|
+
'DK' => '_denmark',
|
65
|
+
'DJ' => '_djibouti',
|
66
|
+
'DM' => '_dominica',
|
67
|
+
'DO' => '_dominicanRepublic',
|
68
|
+
'TP' => '_eastTimor',
|
69
|
+
'EC' => '_ecuador',
|
70
|
+
'EG' => '_egypt',
|
71
|
+
'SV' => '_elSalvador',
|
72
|
+
'GU' => '_equatorialGuinea',
|
73
|
+
'ER' => '_eritrea',
|
74
|
+
'EE' => '_estonia',
|
75
|
+
'ET' => '_ethiopia',
|
76
|
+
'FK' => '_falklandIslandsMalvina',
|
77
|
+
'FO' => '_faroeIslands',
|
78
|
+
'FJ' => '_fiji',
|
79
|
+
'FI' => '_finland',
|
80
|
+
'FR' => '_france',
|
81
|
+
'GF' => '_frenchGuiana',
|
82
|
+
'PF' => '_frenchPolynesia',
|
83
|
+
'TF' => '_frenchSouthernTerritories',
|
84
|
+
'GA' => '_gabon',
|
85
|
+
'GM' => '_gambia',
|
86
|
+
'GE' => '_georgia',
|
87
|
+
'DE' => '_germany',
|
88
|
+
'GH' => '_ghana',
|
89
|
+
'GI' => '_gibraltar',
|
90
|
+
'GR' => '_greece',
|
91
|
+
'GL' => '_greenland',
|
92
|
+
'GD' => '_grenada',
|
93
|
+
'GP' => '_guadeloupe',
|
94
|
+
'GU' => '_guam',
|
95
|
+
'GT' => '_guatemala',
|
96
|
+
'GG' => '_guernsey',
|
97
|
+
'GN' => '_guinea',
|
98
|
+
'GW' => '_guineaBissau',
|
99
|
+
'GY' => '_guyana',
|
100
|
+
'HT' => '_haiti',
|
101
|
+
'HM' => '_heardAndMcDonaldIslands',
|
102
|
+
'VA' => '_holySeeCityVaticanState',
|
103
|
+
'HN' => '_honduras',
|
104
|
+
'HK' => '_hongKong',
|
105
|
+
'HU' => '_hungary',
|
106
|
+
'IS' => '_iceland',
|
107
|
+
'IN' => '_india',
|
108
|
+
'ID' => '_indonesia',
|
109
|
+
'IR' => '_iranIslamicRepublicOf',
|
110
|
+
'IQ' => '_iraq',
|
111
|
+
'IE' => '_ireland',
|
112
|
+
'IM' => '_isleOfMan',
|
113
|
+
'IL' => '_israel',
|
114
|
+
'IT' => '_italy',
|
115
|
+
'JM' => '_jamaica',
|
116
|
+
'JP' => '_japan',
|
117
|
+
'JE' => '_jersey',
|
118
|
+
'JO' => '_jordan',
|
119
|
+
'KZ' => '_kazakhstan',
|
120
|
+
'KE' => '_kenya',
|
121
|
+
'KI' => '_kiribati',
|
122
|
+
'KP' => '_koreaDemocraticPeoplesRepublic',
|
123
|
+
'KR' => '_koreaRepublicOf',
|
124
|
+
'KW' => '_kuwait',
|
125
|
+
'KG' => '_kyrgyzstan',
|
126
|
+
'LA' => '_laoPeoplesDemocraticRepublic',
|
127
|
+
'LV' => '_latvia',
|
128
|
+
'LB' => '_lebanon',
|
129
|
+
'LS' => '_lesotho',
|
130
|
+
'LR' => '_liberia',
|
131
|
+
'LY' => '_libyanArabJamahiriya',
|
132
|
+
'LI' => '_liechtenstein',
|
133
|
+
'LT' => '_lithuania',
|
134
|
+
'LU' => '_luxembourg',
|
135
|
+
'MO' => '_macau',
|
136
|
+
'MK' => '_macedonia',
|
137
|
+
'MG' => '_madagascar',
|
138
|
+
'MW' => '_malawi',
|
139
|
+
'MY' => '_malaysia',
|
140
|
+
'MV' => '_maldives',
|
141
|
+
'ML' => '_mali',
|
142
|
+
'MT' => '_malta',
|
143
|
+
'MH' => '_marshallIslands',
|
144
|
+
'MQ' => '_martinique',
|
145
|
+
'MR' => '_mauritania',
|
146
|
+
'MU' => '_mauritius',
|
147
|
+
'YT' => '_mayotte',
|
148
|
+
'MX' => '_mexico',
|
149
|
+
'FM' => '_micronesiaFederalStateOf',
|
150
|
+
'MD' => '_moldovaRepublicOf',
|
151
|
+
'MC' => '_monaco',
|
152
|
+
'MN' => '_mongolia',
|
153
|
+
'ME' => '_montenegro',
|
154
|
+
'MS' => '_montserrat',
|
155
|
+
'MA' => '_morocco',
|
156
|
+
'MZ' => '_mozambique',
|
157
|
+
'MM' => '_myanmar',
|
158
|
+
'NA' => '_namibia',
|
159
|
+
'NR' => '_nauru',
|
160
|
+
'NP' => '_nepal',
|
161
|
+
'NL' => '_netherlands',
|
162
|
+
'AN' => '_netherlandsAntilles',
|
163
|
+
'NC' => '_newCaledonia',
|
164
|
+
'NZ' => '_newZealand',
|
165
|
+
'NI' => '_nicaragua',
|
166
|
+
'NE' => '_niger',
|
167
|
+
'NG' => '_nigeria',
|
168
|
+
'NU' => '_niue',
|
169
|
+
'NF' => '_norfolkIsland',
|
170
|
+
'MP' => '_northernMarianaIslands',
|
171
|
+
'NO' => '_norway',
|
172
|
+
'OM' => '_oman',
|
173
|
+
'PK' => '_pakistan',
|
174
|
+
'PW' => '_palau',
|
175
|
+
'PS' => '_palestinianTerritories',
|
176
|
+
'PA' => '_panama',
|
177
|
+
'PG' => '_papuaNewGuinea',
|
178
|
+
'PY' => '_paraguay',
|
179
|
+
'PE' => '_peru',
|
180
|
+
'PH' => '_philippines',
|
181
|
+
'PN' => '_pitcairnIsland',
|
182
|
+
'PL' => '_poland',
|
183
|
+
'PT' => '_portugal',
|
184
|
+
'PR' => '_puertoRico',
|
185
|
+
'QA' => '_qatar',
|
186
|
+
'RE' => '_reunionIsland',
|
187
|
+
'RO' => '_romania',
|
188
|
+
'RU' => '_russianFederation',
|
189
|
+
'RW' => '_rwanda',
|
190
|
+
'BL' => '_saintBarthelemy',
|
191
|
+
'KN' => '_saintKittsAndNevis',
|
192
|
+
'LC' => '_saintLucia',
|
193
|
+
'VC' => '_saintVincentAndTheGrenadines',
|
194
|
+
'SM' => '_sanMarino',
|
195
|
+
'ST' => '_saoTomeAndPrincipe',
|
196
|
+
'SA' => '_saudiArabia',
|
197
|
+
'SN' => '_senegal',
|
198
|
+
'CS' => '_serbia',
|
199
|
+
'SC' => '_seychelles',
|
200
|
+
'SL' => '_sierraLeone',
|
201
|
+
'SG' => '_singapore',
|
202
|
+
'SX' => '_sintMaarten',
|
203
|
+
'SK' => '_slovakRepublic',
|
204
|
+
'SI' => '_slovenia',
|
205
|
+
'SB' => '_solomonIslands',
|
206
|
+
'SO' => '_somalia',
|
207
|
+
'ZA' => '_southAfrica',
|
208
|
+
'GS' => '_southGeorgia',
|
209
|
+
'ES' => '_spain',
|
210
|
+
'LK' => '_sriLanka',
|
211
|
+
'SH' => '_stHelena',
|
212
|
+
'PM' => '_stPierreAndMiquelon',
|
213
|
+
'SD' => '_sudan',
|
214
|
+
'SR' => '_suriname',
|
215
|
+
'SJ' => '_svalbardAndJanMayenIslands',
|
216
|
+
'SZ' => '_swaziland',
|
217
|
+
'SE' => '_sweden',
|
218
|
+
'CH' => '_switzerland',
|
219
|
+
'SY' => '_syrianArabRepublic',
|
220
|
+
'TW' => '_taiwan',
|
221
|
+
'TJ' => '_tajikistan',
|
222
|
+
'TZ' => '_tanzania',
|
223
|
+
'TH' => '_thailand',
|
224
|
+
'TG' => '_togo',
|
225
|
+
'TK' => '_tokelau',
|
226
|
+
'TO' => '_tonga',
|
227
|
+
'TT' => '_trinidadAndTobago',
|
228
|
+
'TN' => '_tunisia',
|
229
|
+
'TR' => '_turkey',
|
230
|
+
'TM' => '_turkmenistan',
|
231
|
+
'TC' => '_turksAndCaicosIslands',
|
232
|
+
'TV' => '_tuvalu',
|
233
|
+
'UG' => '_uganda',
|
234
|
+
'UA' => '_ukraine',
|
235
|
+
'AE' => '_unitedArabEmirates',
|
236
|
+
'GB' => '_unitedKingdomGB',
|
237
|
+
'US' => '_unitedStates',
|
238
|
+
'UY' => '_uruguay',
|
239
|
+
'UM' => '_uSMinorOutlyingIslands',
|
240
|
+
'UZ' => '_uzbekistan',
|
241
|
+
'VU' => '_vanuatu',
|
242
|
+
'VE' => '_venezuela',
|
243
|
+
'VN' => '_vietnam',
|
244
|
+
'VG' => '_virginIslandsBritish',
|
245
|
+
'VI' => '_virginIslandsUSA',
|
246
|
+
'WF' => '_wallisAndFutunaIslands',
|
247
|
+
'EH' => '_westernSahara',
|
248
|
+
'WS' => '_westernSamoa',
|
249
|
+
'YE' => '_yemen',
|
250
|
+
'YU' => '_yugoslavia',
|
251
|
+
'ZM' => '_zambia',
|
252
|
+
'ZW' => '_zimbabwe'
|
253
|
+
}
|
254
|
+
|
255
|
+
def initialize(iso_or_name)
|
256
|
+
if iso_or_name =~ /[A-Z]{2}/
|
257
|
+
@id = ISO_TO_NETSUITE.fetch(iso_or_name)
|
258
|
+
else
|
259
|
+
@id = iso_or_name
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def to_iso
|
264
|
+
ISO_TO_NETSUITE.key(@id)
|
265
|
+
end
|
266
|
+
|
267
|
+
def to_record
|
268
|
+
@id
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
@@ -2,7 +2,9 @@ module NetSuite
|
|
2
2
|
module Support
|
3
3
|
class SearchResult
|
4
4
|
attr_accessor :response
|
5
|
+
|
5
6
|
attr_reader :total_records
|
7
|
+
attr_reader :total_pages
|
6
8
|
|
7
9
|
# header from a basic customer search:
|
8
10
|
|
@@ -17,7 +19,9 @@ module NetSuite
|
|
17
19
|
def initialize(response, result_class)
|
18
20
|
@result_class = result_class
|
19
21
|
@response = response
|
22
|
+
|
20
23
|
@total_records = response.body[:total_records].to_i
|
24
|
+
@total_pages = response.body[:total_pages].to_i
|
21
25
|
|
22
26
|
if @total_records > 0
|
23
27
|
if response.body.has_key?(:record_list)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Support
|
3
|
+
class Sublist
|
4
|
+
include Support::Fields
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def sublist(key, klass)
|
9
|
+
field key
|
10
|
+
|
11
|
+
# TODO setting class methods might be better? How to reach into the subclass?
|
12
|
+
|
13
|
+
define_method(:sublist_key) { key }
|
14
|
+
define_method(:sublist_class) { klass }
|
15
|
+
|
16
|
+
define_method("#{key}=") do |list|
|
17
|
+
self.process_sublist(list)
|
18
|
+
end
|
19
|
+
|
20
|
+
define_method("#{key}") do
|
21
|
+
@list ||= []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
field :replace_all
|
28
|
+
|
29
|
+
def initialize(attributes = {})
|
30
|
+
initialize_from_attributes_hash(attributes)
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_record
|
34
|
+
rec = { "#{record_namespace}:#{sublist_key.to_s.lower_camelcase}" => send(self.sublist_key).map(&:to_record) }
|
35
|
+
|
36
|
+
if !replace_all.nil?
|
37
|
+
rec["#{record_namespace}:replaceAll"] = replace_all
|
38
|
+
end
|
39
|
+
|
40
|
+
rec
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def process_sublist(list)
|
45
|
+
list = [ list ] if !list.is_a?(Array)
|
46
|
+
|
47
|
+
@list = list.map do |item|
|
48
|
+
self.sublist_class.new(item)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|