netsuite 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +32 -0
  3. data/lib/netsuite.rb +5 -1
  4. data/lib/netsuite/actions/add.rb +4 -4
  5. data/lib/netsuite/actions/delete.rb +7 -7
  6. data/lib/netsuite/actions/get.rb +5 -5
  7. data/lib/netsuite/actions/get_list.rb +24 -11
  8. data/lib/netsuite/actions/get_select_value.rb +5 -5
  9. data/lib/netsuite/actions/initialize.rb +5 -5
  10. data/lib/netsuite/actions/login.rb +33 -0
  11. data/lib/netsuite/actions/search.rb +5 -5
  12. data/lib/netsuite/actions/update.rb +5 -5
  13. data/lib/netsuite/actions/upsert.rb +4 -4
  14. data/lib/netsuite/configuration.rb +9 -9
  15. data/lib/netsuite/records/account.rb +1 -1
  16. data/lib/netsuite/records/custom_field_list.rb +2 -0
  17. data/lib/netsuite/records/custom_record.rb +1 -1
  18. data/lib/netsuite/records/customer.rb +9 -6
  19. data/lib/netsuite/records/deposit.rb +2 -2
  20. data/lib/netsuite/records/deposit_cash_back.rb +42 -0
  21. data/lib/netsuite/records/deposit_cash_back_list.rb +32 -0
  22. data/lib/netsuite/records/deposit_other.rb +45 -0
  23. data/lib/netsuite/records/deposit_other_list.rb +32 -0
  24. data/lib/netsuite/records/item_fulfillment.rb +7 -1
  25. data/lib/netsuite/records/item_fulfillment_item.rb +1 -1
  26. data/lib/netsuite/records/item_fulfillment_package_list.rb +22 -1
  27. data/lib/netsuite/records/sales_order.rb +1 -1
  28. data/lib/netsuite/records/service_sale_item.rb +1 -1
  29. data/lib/netsuite/support/requests.rb +5 -4
  30. data/lib/netsuite/version.rb +1 -1
  31. data/netsuite.gemspec +1 -1
  32. data/spec/netsuite/actions/add_spec.rb +5 -5
  33. data/spec/netsuite/actions/delete_spec.rb +2 -2
  34. data/spec/netsuite/actions/get_spec.rb +4 -4
  35. data/spec/netsuite/actions/initialize_spec.rb +2 -2
  36. data/spec/netsuite/actions/search_spec.rb +6 -6
  37. data/spec/netsuite/actions/update_spec.rb +4 -4
  38. data/spec/netsuite/actions/upsert_spec.rb +5 -5
  39. data/spec/netsuite/records/account_spec.rb +6 -6
  40. data/spec/netsuite/records/accounting_period_spec.rb +6 -6
  41. data/spec/netsuite/records/classification_spec.rb +4 -4
  42. data/spec/netsuite/records/credit_memo_spec.rb +8 -8
  43. data/spec/netsuite/records/custom_field_list_spec.rb +10 -0
  44. data/spec/netsuite/records/custom_field_spec.rb +1 -1
  45. data/spec/netsuite/records/custom_record_ref_spec.rb +1 -1
  46. data/spec/netsuite/records/custom_record_spec.rb +6 -6
  47. data/spec/netsuite/records/custom_record_type_spec.rb +6 -6
  48. data/spec/netsuite/records/customer_payment_spec.rb +9 -9
  49. data/spec/netsuite/records/customer_refund_spec.rb +8 -8
  50. data/spec/netsuite/records/customer_spec.rb +10 -10
  51. data/spec/netsuite/records/department_spec.rb +6 -6
  52. data/spec/netsuite/records/deposit_spec.rb +10 -10
  53. data/spec/netsuite/records/inventory_item_spec.rb +6 -6
  54. data/spec/netsuite/records/invoice_spec.rb +8 -8
  55. data/spec/netsuite/records/item_fulfillment_package_list_spec.rb +27 -0
  56. data/spec/netsuite/records/item_fulfillment_spec.rb +49 -0
  57. data/spec/netsuite/records/job_spec.rb +8 -8
  58. data/spec/netsuite/records/journal_entry_spec.rb +6 -6
  59. data/spec/netsuite/records/location_spec.rb +2 -2
  60. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +6 -6
  61. data/spec/netsuite/records/payment_method_spec.rb +2 -2
  62. data/spec/netsuite/records/rev_rec_template_spec.rb +2 -2
  63. data/spec/netsuite/records/sales_order_spec.rb +9 -9
  64. data/spec/netsuite/records/service_sale_item_spec.rb +6 -6
  65. data/spec/netsuite/records/support_case_spec.rb +8 -8
  66. data/spec/netsuite/records/term_spec.rb +6 -6
  67. data/spec/netsuite/support/actions_spec.rb +1 -1
  68. data/spec/netsuite/support/attributes_spec.rb +1 -1
  69. data/spec/spec_helper.rb +1 -1
  70. metadata +13 -5
  71. data/lib/netsuite/actions/search_more_with_id.rb +0 -107
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add, :delete, :search
10
+ actions :get, :add, :delete, :search, :upsert
11
11
 
12
12
  fields :acct_name, :acct_number, :acct_type, :cash_flow_rate, :cur_doc_num, :description, :eliminate, :exchange_rate,
13
13
  :general_rate, :include_children, :inventory, :is_inactive, :opening_balance, :revalue, :tran_date
@@ -100,6 +100,8 @@ module NetSuite
100
100
  custom_field_value = case
101
101
  when field_value.is_a?(Hash)
102
102
  CustomRecordRef.new(field_value)
103
+ when field_value.is_a?(Date)
104
+ field_value.to_datetime.iso8601
103
105
  when field_value.is_a?(Time)
104
106
  field_value.iso8601
105
107
  when field_value.is_a?(Array)
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::SetupCustom
9
9
 
10
- actions :get, :get_list, :add, :delete, :search
10
+ actions :get, :update, :get_list, :add, :delete, :search
11
11
 
12
12
  fields :allow_attachments, :allow_inline_editing, :allow_numbering_override, :allow_quick_search, :created,
13
13
  :custom_record_id, :description, :disclaimer, :enabl_email_merge, :enable_numbering, :include_name,
@@ -9,19 +9,22 @@ module NetSuite
9
9
 
10
10
  actions :get, :get_list, :add, :update, :upsert, :delete, :search
11
11
 
12
+ # See https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2014_1/schema/record/customer.html
13
+ # for the complete list of attributes their descriptions
14
+
12
15
  fields :access_role, :account_number, :aging, :alt_email, :alt_name, :alt_phone, :bill_pay,
13
- :buying_reason, :buying_time_frame, :campaign_category, :category, :click_stream, :comments, :company_name,
16
+ :buying_reason, :buying_time_frame, :campaign_category, :click_stream, :comments, :company_name,
14
17
  :consol_aging, :consol_days_overdue, :contact_roles_list, :contrib_pct, :credit_cards_list, :credit_hold_override,
15
18
  :credit_limit, :currency, :currency_list, :date_created, :days_overdue, :default_address,
16
19
  :download_list, :email, :email_preference, :email_transactions, :end_date, :entity_id,
17
20
  :estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status,
18
21
  :group_pricing_list, :home_phone, :image, :is_budget_approved, :is_inactive, :is_person, :item_pricing_list, :keywords,
19
- :language, :last_modified_date, :last_name, :last_page_visited, :last_visit, :lead_source, :middle_name, :mobile_phone,
22
+ :language, :last_modified_date, :last_name, :last_page_visited, :last_visit, :middle_name, :mobile_phone,
20
23
  :opening_balance, :opening_balance_account, :opening_balance_date, :parent, :partners_list,
21
- :password, :password2, :phone, :phonetic_name, :pref_cc_processor, :price_level, :print_on_check_as,
24
+ :password, :password2, :phone, :phonetic_name, :pref_cc_processor, :print_on_check_as,
22
25
  :print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number,
23
26
  :sales_group, :sales_readiness, :sales_rep, :sales_team_list, :salutation, :send_email, :ship_complete, :shipping_item,
24
- :stage, :start_date, :subscriptions_list, :subsidiary, :sync_partner_teams, :tax_exempt, :tax_item, :taxable, :terms,
27
+ :stage, :start_date, :subscriptions_list, :sync_partner_teams, :tax_exempt, :tax_item, :taxable, :terms,
25
28
  :territory, :third_party_acct, :third_party_country, :third_party_zipcode, :title, :url,
26
29
  :vat_reg_number, :visits, :web_lead
27
30
 
@@ -31,7 +34,8 @@ module NetSuite
31
34
  read_only_fields :balance, :consol_balance, :deposit_balance, :consol_deposit_balance, :overdue_balance,
32
35
  :consol_overdue_balance, :unbilled_orders, :consol_unbilled_orders
33
36
 
34
- record_refs :custom_form, :entity_status, :partner
37
+ record_refs :custom_form, :entity_status, :partner, :category, :lead_source,
38
+ :price_level, :subsidiary
35
39
 
36
40
  attr_reader :internal_id
37
41
  attr_accessor :external_id
@@ -50,7 +54,6 @@ module NetSuite
50
54
  end
51
55
  rec
52
56
  end
53
-
54
57
  end
55
58
  end
56
59
  end
@@ -14,8 +14,8 @@ module NetSuite
14
14
  record_refs :custom_form, :account, :posting_period, :subsidiary, :department, :klass, :location
15
15
 
16
16
  field :payment_list, DepositPaymentList
17
- # field :other_list, DepositOtherList
18
- # field :cash_back_list, DepositCashBackList
17
+ field :other_list, DepositOtherList
18
+ field :cash_back_list, DepositCashBackList
19
19
  field :custom_field_list, CustomFieldList
20
20
 
21
21
  attr_reader :internal_id
@@ -0,0 +1,42 @@
1
+ module NetSuite
2
+ module Records
3
+ class DepositCashBack
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranBank
8
+
9
+ # <element name="amount" type="xsd:double" minOccurs="0"/>
10
+ # <element name="account" type="platformCore:RecordRef" minOccurs="0"/>
11
+ # <element name="department" type="platformCore:RecordRef" minOccurs="0"/>
12
+ # <element name="class" type="platformCore:RecordRef" minOccurs="0"/>
13
+ # <element name="location" type="platformCore:RecordRef" minOccurs="0"/>
14
+ # <element name="memo" type="xsd:string" minOccurs="0"/>
15
+
16
+ fields :amount, :memo
17
+
18
+ record_refs :account, :department, :class, :location
19
+
20
+ def initialize(attributes_or_record = {})
21
+ case attributes_or_record
22
+ when Hash
23
+ initialize_from_attributes_hash(attributes_or_record)
24
+ when self.class
25
+ initialize_from_record(attributes_or_record)
26
+ end
27
+ end
28
+
29
+ def initialize_from_record(record)
30
+ self.attributes = record.send(:attributes)
31
+ end
32
+
33
+ def to_record
34
+ rec = super
35
+ if rec["#{record_namespace}:customFieldList"]
36
+ rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
37
+ end
38
+ rec
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class DepositCashBackList
4
+ include Support::Fields
5
+ include Namespaces::TranBank
6
+
7
+ fields :deposit_cash_back
8
+
9
+ def initialize(attributes = {})
10
+ initialize_from_attributes_hash(attributes)
11
+ end
12
+
13
+ def cashback=(cashbacks)
14
+ case cashbacks
15
+ when Hash
16
+ self.cashbacks << DepositCashBack.new(cashbacks)
17
+ when Array
18
+ cashbacks.each { |cb| self.cashbacks << DepositCashBack.new(cb) }
19
+ end
20
+ end
21
+
22
+ def cashbacks
23
+ @cashbacks ||= []
24
+ end
25
+
26
+ def to_record
27
+ { "#{record_namespace}:depositCashBack" => cashbacks.map(&:to_record) }
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ module NetSuite
2
+ module Records
3
+ class DepositOther
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranBank
8
+
9
+ # <element name="entity" type="platformCore:RecordRef" minOccurs="0"/>
10
+ # <element name="amount" type="xsd:double" minOccurs="0"/>
11
+ # <element name="account" type="platformCore:RecordRef" minOccurs="0"/>
12
+ # <element name="paymentMethod" type="platformCore:RecordRef" minOccurs="0"/>
13
+ # <element name="refNum" type="xsd:string" minOccurs="0"/>
14
+ # <element name="department" type="platformCore:RecordRef" minOccurs="0"/>
15
+ # <element name="class" type="platformCore:RecordRef" minOccurs="0"/>
16
+ # <element name="location" type="platformCore:RecordRef" minOccurs="0"/>
17
+ # <element name="memo" type="xsd:string" minOccurs="0"/>
18
+
19
+ fields :amount, :ref_num, :memo
20
+
21
+ record_refs :entity, :account, :payment_method, :department, :class, :location
22
+
23
+ def initialize(attributes_or_record = {})
24
+ case attributes_or_record
25
+ when Hash
26
+ initialize_from_attributes_hash(attributes_or_record)
27
+ when self.class
28
+ initialize_from_record(attributes_or_record)
29
+ end
30
+ end
31
+
32
+ def initialize_from_record(record)
33
+ self.attributes = record.send(:attributes)
34
+ end
35
+
36
+ def to_record
37
+ rec = super
38
+ if rec["#{record_namespace}:customFieldList"]
39
+ rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
40
+ end
41
+ rec
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class DepositOtherList
4
+ include Support::Fields
5
+ include Namespaces::TranBank
6
+
7
+ fields :deposit_other
8
+
9
+ def initialize(attributes = {})
10
+ initialize_from_attributes_hash(attributes)
11
+ end
12
+
13
+ def other=(others)
14
+ case others
15
+ when Hash
16
+ self.others << DepositOther.new(others)
17
+ when Array
18
+ others.each { |cb| self.others << DepositOther.new(cb) }
19
+ end
20
+ end
21
+
22
+ def others
23
+ @others ||= []
24
+ end
25
+
26
+ def to_record
27
+ { "#{record_namespace}:depositOther" => others.map(&:to_record) }
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -11,7 +11,7 @@ module NetSuite
11
11
 
12
12
  fields :tran_date, :tran_id, :shipping_cost, :memo, :ship_company, :ship_attention, :ship_addr1,
13
13
  :ship_addr2, :ship_city, :ship_state, :ship_zip, :ship_phone, :ship_is_residential,
14
- :ship_status
14
+ :ship_status, :last_modified_date
15
15
 
16
16
  read_only_fields :handling_cost
17
17
 
@@ -29,6 +29,12 @@ module NetSuite
29
29
  def initialize(attributes = {})
30
30
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
31
31
  @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
32
+
33
+ if !attributes.empty? && attributes[:package_ups_list]
34
+ attributes[:package_list] ||= {}
35
+ attributes[:package_list].merge! attributes[:package_ups_list]
36
+ end
37
+
32
38
  initialize_from_attributes_hash(attributes)
33
39
  end
34
40
 
@@ -42,4 +42,4 @@ module NetSuite
42
42
  end
43
43
  end
44
44
  end
45
- end
45
+ end
@@ -8,6 +8,27 @@ module NetSuite
8
8
  fields :package
9
9
 
10
10
  def initialize(attributes = {})
11
+ if attributes.keys != [:package] && attributes.first
12
+
13
+ transformed_attrs = {}
14
+ object = attributes.first.last
15
+
16
+ case object
17
+ when Hash
18
+ object.each do |k, v|
19
+ transformed_attrs.merge!(k[0..-5].to_sym => v)
20
+ end
21
+ when Array
22
+ object.each do |hash|
23
+ hash.each do |k, v|
24
+ transformed_attrs.merge!(k[0..-5].to_sym => v)
25
+ end
26
+ end
27
+ end
28
+
29
+ attributes = { package: transformed_attrs }
30
+ end
31
+
11
32
  initialize_from_attributes_hash(attributes)
12
33
  end
13
34
 
@@ -25,7 +46,7 @@ module NetSuite
25
46
  end
26
47
 
27
48
  def to_record
28
- { "#{record_namespace}:package" => items.map(&:to_record) }
49
+ { "#{record_namespace}:package" => packages.map(&:to_record) }
29
50
  end
30
51
  end
31
52
  end
@@ -28,7 +28,7 @@ module NetSuite
28
28
 
29
29
  record_refs :account, :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item, :entity, :gift_cert,
30
30
  :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :opportunity, :partner, :posting_period, :promo_code,
31
- :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :terms, :tax_item
31
+ :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :terms, :tax_item, :payment_method
32
32
 
33
33
  attr_reader :internal_id
34
34
  attr_accessor :external_id
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add, :delete
10
+ actions :get, :add, :delete, :upsert
11
11
 
12
12
  fields :available_to_partners, :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,
@@ -8,14 +8,15 @@ module NetSuite
8
8
 
9
9
  module ClassMethods
10
10
 
11
- def call(*args)
12
- new(*args).call
11
+ def call(options, credentials={})
12
+ raise ArgumentError, "options should be an array" unless options.is_a?(Array)
13
+ new(*options).call(credentials)
13
14
  end
14
15
 
15
16
  end
16
17
 
17
- def call
18
- @response = request
18
+ def call(credentials={})
19
+ @response = request(credentials)
19
20
  build_response
20
21
  end
21
22
 
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -17,5 +17,5 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency 'savon', '~> 2.3.0'
19
19
 
20
- gem.add_development_dependency 'rspec', '~> 2.10'
20
+ gem.add_development_dependency 'rspec', '~> 2.99'
21
21
  end
@@ -22,11 +22,11 @@ describe NetSuite::Actions::Add do
22
22
  end
23
23
 
24
24
  it 'makes a valid request to the NetSuite API' do
25
- NetSuite::Actions::Add.call(customer)
25
+ NetSuite::Actions::Add.call([customer])
26
26
  end
27
27
 
28
28
  it 'returns a valid Response object' do
29
- response = NetSuite::Actions::Add.call(customer)
29
+ response = NetSuite::Actions::Add.call([customer])
30
30
  response.should be_kind_of(NetSuite::Response)
31
31
  response.should be_success
32
32
  end
@@ -50,11 +50,11 @@ describe NetSuite::Actions::Add do
50
50
  end
51
51
 
52
52
  it 'makes a valid request to the NetSuite API' do
53
- NetSuite::Actions::Add.call(invoice)
53
+ NetSuite::Actions::Add.call([invoice])
54
54
  end
55
55
 
56
56
  it 'returns a valid Response object' do
57
- response = NetSuite::Actions::Add.call(invoice)
57
+ response = NetSuite::Actions::Add.call([invoice])
58
58
  response.should be_kind_of(NetSuite::Response)
59
59
  response.should be_success
60
60
  end
@@ -83,7 +83,7 @@ describe NetSuite::Actions::Add do
83
83
  end
84
84
 
85
85
  it 'provides an error method on the response' do
86
- response = NetSuite::Actions::Add.call(invoice)
86
+ response = NetSuite::Actions::Add.call([invoice])
87
87
  response.errors.first.should be_kind_of(NetSuite::Error)
88
88
  end
89
89
  end
@@ -20,11 +20,11 @@ describe NetSuite::Actions::Delete do
20
20
  end
21
21
 
22
22
  it 'makes a valid request to the NetSuite API' do
23
- NetSuite::Actions::Delete.call(customer)
23
+ NetSuite::Actions::Delete.call([customer])
24
24
  end
25
25
 
26
26
  it 'returns a valid Response object' do
27
- response = NetSuite::Actions::Delete.call(customer)
27
+ response = NetSuite::Actions::Delete.call([customer])
28
28
  response.should be_kind_of(NetSuite::Response)
29
29
  response.should be_success
30
30
  end
@@ -19,11 +19,11 @@ describe NetSuite::Actions::Get do
19
19
  end
20
20
 
21
21
  it 'makes a valid request to the NetSuite API' do
22
- NetSuite::Actions::Get.call(NetSuite::Records::Customer, :external_id => 1)
22
+ NetSuite::Actions::Get.call([NetSuite::Records::Customer, :external_id => 1])
23
23
  end
24
24
 
25
25
  it 'returns a valid Response object' do
26
- response = NetSuite::Actions::Get.call(NetSuite::Records::Customer, :external_id => 1)
26
+ response = NetSuite::Actions::Get.call([NetSuite::Records::Customer, :external_id => 1])
27
27
  response.should be_kind_of(NetSuite::Response)
28
28
  end
29
29
  end
@@ -60,11 +60,11 @@ describe NetSuite::Actions::Get do
60
60
  end
61
61
 
62
62
  it 'makes a valid request to the NetSuite API' do
63
- NetSuite::Actions::Get.call(NetSuite::Records::Invoice, :external_id => 1)
63
+ NetSuite::Actions::Get.call([NetSuite::Records::Invoice, :external_id => 1])
64
64
  end
65
65
 
66
66
  it 'returns a valid Response object' do
67
- response = NetSuite::Actions::Get.call(NetSuite::Records::Invoice, :external_id => 1)
67
+ response = NetSuite::Actions::Get.call([NetSuite::Records::Invoice, :external_id => 1])
68
68
  response.should be_kind_of(NetSuite::Response)
69
69
  end
70
70
  end
@@ -22,11 +22,11 @@ describe NetSuite::Actions::Initialize do
22
22
  end
23
23
 
24
24
  it 'makes a valid request to the NetSuite API' do
25
- NetSuite::Actions::Initialize.call(NetSuite::Records::Customer, customer)
25
+ NetSuite::Actions::Initialize.call([NetSuite::Records::Customer, customer])
26
26
  end
27
27
 
28
28
  it 'returns a valid Response object' do
29
- response = NetSuite::Actions::Initialize.call(NetSuite::Records::Customer, customer)
29
+ response = NetSuite::Actions::Initialize.call([NetSuite::Records::Customer, customer])
30
30
  response.should be_kind_of(NetSuite::Response)
31
31
  response.should be_success
32
32
  end