netsuite 0.8.1 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +7 -2
  5. data/README.md +111 -31
  6. data/circle.yml +33 -13
  7. data/lib/netsuite.rb +40 -19
  8. data/lib/netsuite/actions/login.rb +25 -2
  9. data/lib/netsuite/actions/search.rb +1 -6
  10. data/lib/netsuite/actions/update.rb +6 -2
  11. data/lib/netsuite/actions/update_list.rb +109 -0
  12. data/lib/netsuite/actions/upsert.rb +2 -0
  13. data/lib/netsuite/configuration.rb +21 -4
  14. data/lib/netsuite/errors.rb +3 -0
  15. data/lib/netsuite/passports/token.rb +1 -1
  16. data/lib/netsuite/records/assembly_build.rb +4 -1
  17. data/lib/netsuite/records/assembly_item.rb +1 -0
  18. data/lib/netsuite/records/assembly_unbuild.rb +3 -0
  19. data/lib/netsuite/records/bin_number.rb +18 -0
  20. data/lib/netsuite/records/bin_number_list.rb +1 -20
  21. data/lib/netsuite/records/bin_transfer.rb +38 -0
  22. data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
  23. data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
  24. data/lib/netsuite/records/cash_refund.rb +3 -1
  25. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  26. data/lib/netsuite/records/classification.rb +5 -2
  27. data/lib/netsuite/records/contact.rb +2 -1
  28. data/lib/netsuite/records/contact_addressbook.rb +64 -0
  29. data/lib/netsuite/records/contact_addressbook_list.rb +11 -0
  30. data/lib/netsuite/records/custom_field_list.rb +10 -2
  31. data/lib/netsuite/records/custom_record.rb +3 -3
  32. data/lib/netsuite/records/custom_record_ref.rb +1 -0
  33. data/lib/netsuite/records/customer.rb +5 -4
  34. data/lib/netsuite/records/customer_credit_cards.rb +36 -0
  35. data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
  36. data/lib/netsuite/records/customer_deposit.rb +5 -2
  37. data/lib/netsuite/records/customer_payment.rb +1 -0
  38. data/lib/netsuite/records/customer_sales_team.rb +24 -0
  39. data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
  40. data/lib/netsuite/records/customer_status.rb +29 -0
  41. data/lib/netsuite/records/customer_subscription.rb +18 -0
  42. data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
  43. data/lib/netsuite/records/employee.rb +2 -2
  44. data/lib/netsuite/records/entity_custom_field.rb +53 -0
  45. data/lib/netsuite/records/estimate.rb +42 -0
  46. data/lib/netsuite/records/estimate_item.rb +40 -0
  47. data/lib/netsuite/records/estimate_item_list.rb +11 -0
  48. data/lib/netsuite/records/inbound_shipment.rb +33 -0
  49. data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
  50. data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
  51. data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
  52. data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
  53. data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
  54. data/lib/netsuite/records/inventory_adjustment.rb +1 -1
  55. data/lib/netsuite/records/inventory_adjustment_inventory.rb +1 -1
  56. data/lib/netsuite/records/inventory_item.rb +2 -2
  57. data/lib/netsuite/records/invoice.rb +1 -1
  58. data/lib/netsuite/records/item_fulfillment.rb +1 -1
  59. data/lib/netsuite/records/lot_numbered_assembly_item.rb +64 -0
  60. data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
  61. data/lib/netsuite/records/matrix_option_list.rb +12 -4
  62. data/lib/netsuite/records/message.rb +30 -0
  63. data/lib/netsuite/records/non_inventory_resale_item.rb +3 -2
  64. data/lib/netsuite/records/non_inventory_sale_item.rb +2 -1
  65. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  66. data/lib/netsuite/records/partner.rb +1 -1
  67. data/lib/netsuite/records/price.rb +17 -0
  68. data/lib/netsuite/records/price_level.rb +26 -0
  69. data/lib/netsuite/records/price_list.rb +9 -0
  70. data/lib/netsuite/records/pricing.rb +20 -0
  71. data/lib/netsuite/records/pricing_matrix.rb +2 -2
  72. data/lib/netsuite/records/promotions.rb +26 -0
  73. data/lib/netsuite/records/promotions_list.rb +9 -0
  74. data/lib/netsuite/records/return_authorization_item.rb +1 -1
  75. data/lib/netsuite/records/sales_order.rb +1 -0
  76. data/lib/netsuite/records/sales_order_item.rb +12 -5
  77. data/lib/netsuite/records/sales_role.rb +26 -0
  78. data/lib/netsuite/records/sales_tax_item.rb +3 -1
  79. data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
  80. data/lib/netsuite/records/service_resale_item.rb +1 -1
  81. data/lib/netsuite/records/service_sale_item.rb +2 -1
  82. data/lib/netsuite/records/support_case.rb +1 -1
  83. data/lib/netsuite/records/support_case_type.rb +26 -0
  84. data/lib/netsuite/records/task.rb +2 -1
  85. data/lib/netsuite/records/tax_group.rb +2 -2
  86. data/lib/netsuite/records/transaction_body_custom_field.rb +61 -0
  87. data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
  88. data/lib/netsuite/records/transfer_order_item.rb +2 -2
  89. data/lib/netsuite/records/vendor_credit.rb +2 -0
  90. data/lib/netsuite/records/work_order.rb +8 -0
  91. data/lib/netsuite/support/actions.rb +2 -0
  92. data/lib/netsuite/support/country.rb +27 -15
  93. data/lib/netsuite/support/search_result.rb +20 -5
  94. data/lib/netsuite/utilities.rb +86 -21
  95. data/lib/netsuite/version.rb +2 -2
  96. data/netsuite.gemspec +5 -4
  97. data/spec/netsuite/actions/login_spec.rb +23 -0
  98. data/spec/netsuite/actions/update_list_spec.rb +107 -0
  99. data/spec/netsuite/actions/update_spec.rb +42 -0
  100. data/spec/netsuite/configuration_spec.rb +79 -6
  101. data/spec/netsuite/records/address_spec.rb +10 -0
  102. data/spec/netsuite/records/basic_record_spec.rb +12 -1
  103. data/spec/netsuite/records/bin_number_spec.rb +23 -0
  104. data/spec/netsuite/records/classification_spec.rb +10 -1
  105. data/spec/netsuite/records/custom_field_list_spec.rb +39 -4
  106. data/spec/netsuite/records/custom_record_spec.rb +1 -1
  107. data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
  108. data/spec/netsuite/records/customer_sales_team_list_spec.rb +41 -0
  109. data/spec/netsuite/records/customer_spec.rb +44 -2
  110. data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
  111. data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
  112. data/spec/netsuite/records/employee_spec.rb +2 -2
  113. data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
  114. data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
  115. data/spec/netsuite/records/estimate_item_spec.rb +40 -0
  116. data/spec/netsuite/records/estimate_spec.rb +216 -0
  117. data/spec/netsuite/records/inter_company_journal_entry_line_list_spec.rb +26 -0
  118. data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
  119. data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
  120. data/spec/netsuite/records/inventory_item_spec.rb +57 -0
  121. data/spec/netsuite/records/invoice_spec.rb +2 -2
  122. data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
  123. data/spec/netsuite/records/message_spec.rb +49 -0
  124. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
  125. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
  126. data/spec/netsuite/records/partner_spec.rb +141 -0
  127. data/spec/netsuite/records/price_level_spec.rb +16 -0
  128. data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
  129. data/spec/netsuite/records/return_authorization_item_list_spec.rb +2 -2
  130. data/spec/netsuite/records/return_authorization_item_spec.rb +1 -1
  131. data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
  132. data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
  133. data/spec/netsuite/records/support_case_type_spec.rb +22 -0
  134. data/spec/netsuite/records/transaction_body_custom_field_spec.rb +32 -0
  135. data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
  136. data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
  137. data/spec/netsuite/support/search_result_spec.rb +24 -0
  138. data/spec/netsuite/utilities_spec.rb +44 -6
  139. data/spec/spec_helper.rb +5 -4
  140. data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
  141. data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
  142. data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
  143. metadata +104 -8
@@ -9,7 +9,7 @@ module NetSuite
9
9
 
10
10
  actions :get, :get_list, :add, :update, :delete, :upsert, :search
11
11
 
12
- fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
12
+ fields :available_to_partners, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
13
13
  :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description,
14
14
  :include_children, :is_donation_item, :is_fulfillable, :is_gco_compliant, :is_inactive, :is_online, :is_taxable,
15
15
  :item_id, :last_modified_date, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html,
@@ -26,7 +26,7 @@ module NetSuite
26
26
  record_refs :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account,
27
27
  :issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code,
28
28
  :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :store_display_image,
29
- :store_display_thumbnail, :store_item_template, :tax_schedule, :units_type
29
+ :store_display_thumbnail, :store_item_template, :tax_schedule, :units_type, :revenue_recognition_rule
30
30
 
31
31
  field :pricing_matrix, PricingMatrix
32
32
  field :custom_field_list, CustomFieldList
@@ -34,6 +34,7 @@ module NetSuite
34
34
 
35
35
  attr_reader :internal_id
36
36
  attr_accessor :external_id
37
+ attr_accessor :search_joins
37
38
 
38
39
  def initialize(attributes = {})
39
40
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListSupport
9
9
 
10
- actions :get, :get_list, :add, :delete, :update, :upsert
10
+ actions :get, :get_list, :add, :delete, :update, :upsert, :search
11
11
 
12
12
  fields :end_date, :incoming_message, :outgoing_message, :search_solution, :email_form,
13
13
  :internal_only, :title, :case_number, :start_date, :email, :phone, :inbound_email,
@@ -0,0 +1,26 @@
1
+ module NetSuite
2
+ module Records
3
+ class SupportCaseType
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::ListSupport
9
+
10
+ actions :get
11
+
12
+ fields :description, :is_inactive, :name
13
+
14
+ record_refs :insert_before
15
+
16
+ attr_reader :internal_id
17
+ attr_accessor :external_id
18
+
19
+ def initialize(attributes = {})
20
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
21
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
22
+ initialize_from_attributes_hash(attributes)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -11,9 +11,10 @@ module NetSuite
11
11
 
12
12
  fields :title, :send_email, :message, :status, :access_level, :reminder_type,
13
13
  :reminder_minutes, :start_date, :end_date, :due_date, :timed_event,
14
- :created_date, :last_modified_date
14
+ :created_date, :last_modified_date, :priority
15
15
 
16
16
  field :contact_list, ContactList
17
+ field :custom_field_list, CustomFieldList
17
18
 
18
19
  record_refs :assigned, :owner, :company, :contact, :transaction
19
20
 
@@ -7,8 +7,8 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- # NOTE search not available on TaxGroup!
11
-
10
+ # NOTE `get_all` is not available API > 2017_1
11
+ # `search` is available API > 2016_2
12
12
  actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search, :get_all
13
13
 
14
14
  fields :city, :county, :description, :include_children, :is_default, :is_inactive,
@@ -0,0 +1,61 @@
1
+ module NetSuite
2
+ module Records
3
+ class TransactionBodyCustomField
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::SetupCustom
9
+
10
+ actions :get, :get_list, :add, :delete, :update, :upsert, :upsert_list
11
+
12
+ # http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2017_1/schema/record/transactionbodycustomfield.html
13
+ fields(
14
+ :label,
15
+ :store_value,
16
+ :display_type,
17
+ :is_mandatory,
18
+ :default_checked,
19
+ :is_formula,
20
+ :body_assembly_build,
21
+ :body_bom,
22
+ :body_b_tegata,
23
+ :body_customer_payment,
24
+ :body_deposit,
25
+ :body_expense_report,
26
+ :body_inventory_adjustment,
27
+ :body_item_fulfillment,
28
+ :body_item_fulfillment_order,
29
+ :body_item__receipt,
30
+ :body_item__receipt_order,
31
+ :body_journal,
32
+ :body_opportunity,
33
+ :body_other_transaction,
34
+ :body_picking_ticket,
35
+ :body_print_flag,
36
+ :body_print_packing_slip,
37
+ :body_print_statement,
38
+ :body_purchase,
39
+ :body_sale,
40
+ :body_store,
41
+ :body_transfer_order,
42
+ :body_vendor_payment,
43
+ :access_level,
44
+ :search_level,
45
+ :field_type,
46
+ :script_id
47
+ )
48
+
49
+ record_refs :owner
50
+
51
+ attr_reader :internal_id
52
+ attr_accessor :external_id
53
+
54
+ def initialize(attributes = {})
55
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
56
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
57
+ initialize_from_attributes_hash(attributes)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,59 @@
1
+ module NetSuite
2
+ module Records
3
+ class TransactionColumnCustomField
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::SetupCustom
9
+
10
+ actions :get, :get_list, :add, :delete, :update, :upsert, :upsert_list
11
+
12
+ # http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2017_1/schema/record/transactioncolumncustomfield.html
13
+ fields(
14
+ :label,
15
+ :store_value,
16
+ :display_type,
17
+ :is_mandatory,
18
+ :default_checked,
19
+ :is_formula,
20
+ :col_expense,
21
+ :col_purchase,
22
+ :col_sale,
23
+ :col_opportunity,
24
+ :col_store,
25
+ :col_store_hidden,
26
+ :col_journal,
27
+ :col_expense_report,
28
+ :col_time,
29
+ :col_transfer_order,
30
+ :col_item_receipt,
31
+ :col_item_receipt_order,
32
+ :col_item_fulfillment,
33
+ :col_item_fulfillment_order,
34
+ :col_print_flag,
35
+ :col_picking_ticket,
36
+ :col_packing_slip,
37
+ :col_return_form,
38
+ :col_store_with_groups,
39
+ :col_group_on_invoices,
40
+ :col_kit_item,
41
+ :access_level,
42
+ :search_level,
43
+ :field_type,
44
+ :script_id
45
+ )
46
+
47
+ record_refs :owner
48
+
49
+ attr_reader :internal_id
50
+ attr_accessor :external_id
51
+
52
+ def initialize(attributes = {})
53
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
54
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
55
+ initialize_from_attributes_hash(attributes)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Namespaces::TranInvt
8
8
 
9
9
  fields :amount, :average_cost, :klass, :commit_inventory, :description,
10
- :expected_receipt_date, :expected_ship_date, :is_closed, :last_purchase_price,
10
+ :expected_receipt_date, :expected_ship_date, :inventory_detail, :is_closed, :last_purchase_price,
11
11
  :line, :options, :order_priority, :quantity, :quantity_available,
12
12
  :quantity_back_ordered, :quantity_committed, :quantity_fulfilled,
13
13
  :quantity_on_hand, :quantity_packed, :quantity_picked, :quantity_received,
@@ -16,7 +16,7 @@ module NetSuite
16
16
  field :options, CustomFieldList
17
17
  field :custom_field_list, CustomFieldList
18
18
 
19
- record_refs :department, :inventory_detail, :item, :units
19
+ record_refs :department, :item, :units
20
20
 
21
21
  def initialize(attributes_or_record = {})
22
22
  case attributes_or_record
@@ -33,9 +33,11 @@ module NetSuite
33
33
  field :custom_field_list, CustomFieldList
34
34
 
35
35
  attr_reader :internal_id
36
+ attr_accessor :external_id
36
37
 
37
38
  def initialize(attributes = {})
38
39
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
40
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
39
41
  initialize_from_attributes_hash(attributes)
40
42
  end
41
43
 
@@ -33,6 +33,14 @@ module NetSuite
33
33
  @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
34
34
  initialize_from_attributes_hash(attributes)
35
35
  end
36
+
37
+ def self.search_class_name
38
+ "Transaction"
39
+ end
40
+
41
+ def self.search_class_namespace
42
+ 'tranSales'
43
+ end
36
44
  end
37
45
  end
38
46
  end
@@ -42,6 +42,8 @@ module NetSuite
42
42
  self.send(:include, NetSuite::Actions::DeleteList::Support)
43
43
  when :update
44
44
  self.send(:include, NetSuite::Actions::Update::Support)
45
+ when :update_list
46
+ self.send(:include, NetSuite::Actions::UpdateList::Support)
45
47
  when :initialize
46
48
  self.send(:include, NetSuite::Actions::Initialize::Support)
47
49
  else
@@ -4,6 +4,7 @@ module NetSuite
4
4
 
5
5
  ISO_TO_NETSUITE = {
6
6
  'AF' => '_afghanistan',
7
+ 'AX' => '_alandIslands',
7
8
  'AL' => '_albania',
8
9
  'DZ' => '_algeria',
9
10
  'AS' => '_americanSamoa',
@@ -29,6 +30,7 @@ module NetSuite
29
30
  'BM' => '_bermuda',
30
31
  'BT' => '_bhutan',
31
32
  'BO' => '_bolivia',
33
+ 'BQ' => '_bonaireSaintEustatiusAndSaba',
32
34
  'BA' => '_bosniaAndHerzegovina',
33
35
  'BW' => '_botswana',
34
36
  'BV' => '_bouvetIsland',
@@ -41,9 +43,11 @@ module NetSuite
41
43
  'KH' => '_cambodia',
42
44
  'CM' => '_cameroon',
43
45
  'CA' => '_canada',
44
- 'CV' => '_capVerde',
46
+ 'IC' => '_canaryIslands',
47
+ 'CV' => '_capeVerde',
45
48
  'KY' => '_caymanIslands',
46
49
  'CF' => '_centralAfricanRepublic',
50
+ 'EA' => '_ceutaAndMelilla',
47
51
  'TD' => '_chad',
48
52
  'CL' => '_chile',
49
53
  'CN' => '_china',
@@ -65,7 +69,7 @@ module NetSuite
65
69
  'DJ' => '_djibouti',
66
70
  'DM' => '_dominica',
67
71
  'DO' => '_dominicanRepublic',
68
- 'TP' => '_eastTimor',
72
+ 'TL' => '_eastTimor',
69
73
  'EC' => '_ecuador',
70
74
  'EG' => '_egypt',
71
75
  'SV' => '_elSalvador',
@@ -73,7 +77,7 @@ module NetSuite
73
77
  'ER' => '_eritrea',
74
78
  'EE' => '_estonia',
75
79
  'ET' => '_ethiopia',
76
- 'FK' => '_falklandIslandsMalvina',
80
+ 'FK' => '_falklandIslands',
77
81
  'FO' => '_faroeIslands',
78
82
  'FJ' => '_fiji',
79
83
  'FI' => '_finland',
@@ -121,6 +125,7 @@ module NetSuite
121
125
  'KI' => '_kiribati',
122
126
  'KP' => '_koreaDemocraticPeoplesRepublic',
123
127
  'KR' => '_koreaRepublicOf',
128
+ 'XK' => '_kosovo',
124
129
  'KW' => '_kuwait',
125
130
  'KG' => '_kyrgyzstan',
126
131
  'LA' => '_laoPeoplesDemocraticRepublic',
@@ -128,7 +133,7 @@ module NetSuite
128
133
  'LB' => '_lebanon',
129
134
  'LS' => '_lesotho',
130
135
  'LR' => '_liberia',
131
- 'LY' => '_libyanArabJamahiriya',
136
+ 'LY' => '_libya',
132
137
  'LI' => '_liechtenstein',
133
138
  'LT' => '_lithuania',
134
139
  'LU' => '_luxembourg',
@@ -159,7 +164,6 @@ module NetSuite
159
164
  'NR' => '_nauru',
160
165
  'NP' => '_nepal',
161
166
  'NL' => '_netherlands',
162
- 'AN' => '_netherlandsAntilles',
163
167
  'NC' => '_newCaledonia',
164
168
  'NZ' => '_newZealand',
165
169
  'NI' => '_nicaragua',
@@ -172,7 +176,7 @@ module NetSuite
172
176
  'OM' => '_oman',
173
177
  'PK' => '_pakistan',
174
178
  'PW' => '_palau',
175
- 'PS' => '_palestinianTerritories',
179
+ 'PS' => '_stateOfPalestine',
176
180
  'PA' => '_panama',
177
181
  'PG' => '_papuaNewGuinea',
178
182
  'PY' => '_paraguay',
@@ -185,18 +189,19 @@ module NetSuite
185
189
  'QA' => '_qatar',
186
190
  'RE' => '_reunionIsland',
187
191
  'RO' => '_romania',
188
- 'RS' => '_serbia',
189
192
  'RU' => '_russianFederation',
190
193
  'RW' => '_rwanda',
191
194
  'BL' => '_saintBarthelemy',
195
+ 'SH' => '_saintHelena',
192
196
  'KN' => '_saintKittsAndNevis',
193
197
  'LC' => '_saintLucia',
198
+ 'MF' => '_saintMartin',
194
199
  'VC' => '_saintVincentAndTheGrenadines',
195
200
  'SM' => '_sanMarino',
196
201
  'ST' => '_saoTomeAndPrincipe',
197
202
  'SA' => '_saudiArabia',
198
203
  'SN' => '_senegal',
199
- 'CS' => '_serbia',
204
+ 'RS' => '_serbia',
200
205
  'SC' => '_seychelles',
201
206
  'SL' => '_sierraLeone',
202
207
  'SG' => '_singapore',
@@ -207,9 +212,9 @@ module NetSuite
207
212
  'SO' => '_somalia',
208
213
  'ZA' => '_southAfrica',
209
214
  'GS' => '_southGeorgia',
215
+ 'SS' => '_southSudan',
210
216
  'ES' => '_spain',
211
217
  'LK' => '_sriLanka',
212
- 'SH' => '_stHelena',
213
218
  'PM' => '_stPierreAndMiquelon',
214
219
  'SD' => '_sudan',
215
220
  'SR' => '_suriname',
@@ -234,8 +239,7 @@ module NetSuite
234
239
  'UG' => '_uganda',
235
240
  'UA' => '_ukraine',
236
241
  'AE' => '_unitedArabEmirates',
237
- # NOTE GB country code changed on 2016_1
238
- 'GB' => NetSuite::Configuration.api_version <= "2015_2" ? '_unitedKingdomGB' : '_unitedKingdom',
242
+ 'GB' => '_unitedKingdom',
239
243
  'US' => '_unitedStates',
240
244
  'UY' => '_uruguay',
241
245
  'UM' => '_uSMinorOutlyingIslands',
@@ -247,16 +251,15 @@ module NetSuite
247
251
  'VI' => '_virginIslandsUSA',
248
252
  'WF' => '_wallisAndFutunaIslands',
249
253
  'EH' => '_westernSahara',
250
- 'WS' => '_westernSamoa',
254
+ 'WS' => '_samoa',
251
255
  'YE' => '_yemen',
252
- 'YU' => '_yugoslavia',
253
256
  'ZM' => '_zambia',
254
257
  'ZW' => '_zimbabwe'
255
258
  }
256
259
 
257
260
  def initialize(iso_or_name = '')
258
261
  if iso_or_name =~ /^[A-Z]{2}/
259
- @id = ISO_TO_NETSUITE.fetch(iso_or_name)
262
+ @id = iso_to_netsuite.fetch(iso_or_name)
260
263
  else
261
264
  @id = iso_or_name
262
265
  end
@@ -269,13 +272,22 @@ module NetSuite
269
272
  alias :eql? :==
270
273
 
271
274
  def to_iso
272
- ISO_TO_NETSUITE.key(@id)
275
+ iso_to_netsuite.key(@id)
273
276
  end
274
277
 
275
278
  def to_record
276
279
  @id
277
280
  end
278
281
 
282
+ def iso_to_netsuite
283
+ # NOTE GB country code changed on 2016_1
284
+ if NetSuite::Configuration.api_version <= "2015_2"
285
+ ISO_TO_NETSUITE.merge({ 'GB' => '_unitedKingdomGB' })
286
+ else
287
+ ISO_TO_NETSUITE
288
+ end
289
+ end
290
+
279
291
  end
280
292
  end
281
293
  end
@@ -17,9 +17,10 @@ module NetSuite
17
17
  # <platformCore:pageIndex>1</platformCore:pageIndex>
18
18
  # <platformCore:searchId>WEBSERVICES_738944_SB2_03012013650784545962753432_28d96bd280</platformCore:searchId>
19
19
 
20
- def initialize(response, result_class)
20
+ def initialize(response, result_class, credentials)
21
21
  @result_class = result_class
22
22
  @response = response
23
+ @credentials = credentials
23
24
 
24
25
  @total_records = response.body[:total_records].to_i
25
26
  @total_pages = response.body[:total_pages].to_i
@@ -28,8 +29,19 @@ module NetSuite
28
29
  if @total_records > 0
29
30
  if response.body.has_key?(:record_list)
30
31
  # basic search results
31
- record_list = response.body[:record_list][:record]
32
- record_list = [record_list] unless record_list.is_a?(Array)
32
+
33
+ # `recordList` node can contain several nested `record` nodes, only one node or be empty
34
+ # so we have to handle all these cases:
35
+ # * { record_list: nil }
36
+ # * { record_list: { record: => {...} } }
37
+ # * { record_list: { record: => [{...}, {...}, ...] } }
38
+ record_list = if response.body[:record_list].nil?
39
+ []
40
+ elsif response.body[:record_list][:record].is_a?(Array)
41
+ response.body[:record_list][:record]
42
+ else
43
+ [response.body[:record_list][:record]]
44
+ end
33
45
 
34
46
  record_list.each do |record|
35
47
  results << result_class.new(record)
@@ -98,8 +110,11 @@ module NetSuite
98
110
  yield results
99
111
 
100
112
  next_search = @result_class.search(
101
- search_id: @response.body[:search_id],
102
- page_index: @response.body[:page_index].to_i + 1
113
+ {
114
+ search_id: @response.body[:search_id],
115
+ page_index: @response.body[:page_index].to_i + 1
116
+ },
117
+ @credentials
103
118
  )
104
119
 
105
120
  @results = next_search.results