Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CD-6394 add klass #612

Open
wants to merge 115 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
cf1338c
[CLOUD-737-attach-functionality]
reginad1 Nov 5, 2019
55bea99
Merge pull request #1 from CloudsnapInc/add-attach-functionlity
reginad1 Nov 12, 2019
2b61c83
[hotfix-CLOUD-737]
reginad1 Nov 18, 2019
633895a
Merge pull request #2 from CloudsnapInc/fix-add-action-file
reginad1 Nov 18, 2019
f4e02c9
[HOTFIX-CLOUD-737-add-action-for-file]
reginad1 Nov 18, 2019
247a8db
Merge pull request #3 from CloudsnapInc/add-action-for-file
reginad1 Nov 18, 2019
022a6e6
[CLD-597-intercompany-updates]
reginad1 Jan 31, 2020
e4dcb31
[CLD-571-expense-report]
reginad1 Jan 30, 2020
3d77d54
Merge pull request #4 from CloudsnapInc/CLD-597-sales-order
reginad1 Feb 3, 2020
656ca69
Merge pull request #5 from CloudsnapInc/CLD-571-expense-report
reginad1 Feb 3, 2020
439e871
[CLD-659-sales-order-lines]
reginad1 Feb 17, 2020
3ef6d6c
Merge pull request #6 from CloudsnapInc/CLD-619-sales-order-item
reginad1 Feb 20, 2020
fe66da5
[CLD-669-vendorcredit-record-refs]
reginad1 Feb 24, 2020
fe96eff
Merge pull request #7 from CloudsnapInc/CLD-669-vendorcredit
reginad1 Feb 24, 2020
330ffa6
[CLD-725-expenses-on-purchaseorders]
reginad1 Mar 13, 2020
f9b05f7
Merge pull request #8 from CloudsnapInc/CLD-725-purchase-order-expense
reginad1 Mar 16, 2020
7fbe5b2
[CLD-737-item-receipt-expenses]
reginad1 Mar 17, 2020
bc79ecf
Merge pull request #9 from CloudsnapInc/CLD-737-expense-item-receipt
reginad1 Mar 18, 2020
0423790
[CLD-756-Add-Expense-Categories]
reginad1 Mar 25, 2020
99b040d
Merge pull request #10 from CloudsnapInc/CLD-756-Add-Expense-Category
reginad1 Mar 25, 2020
3a3c747
[CLD-882-large-response]
reginad1 Apr 21, 2020
811e421
pry
reginad1 Apr 21, 2020
3d0f984
remove pry
reginad1 Apr 21, 2020
1a2045e
pry
reginad1 Apr 21, 2020
e188a5d
remove pry
reginad1 Apr 21, 2020
28125a4
Merge pull request #11 from CloudsnapInc/increase-timeout
reginad1 Apr 21, 2020
e20132a
[CLD-878-support-later-version]
reginad1 May 2, 2020
16371f7
Merge pull request #12 from CloudsnapInc/update-config-for-versions
reginad1 May 11, 2020
c36ebba
[CLD-917-vendor-credit-klass]
reginad1 May 11, 2020
7db5d5d
Merge pull request #13 from CloudsnapInc/cld-917-class-at-vendorcredit
reginad1 May 11, 2020
ce4b0fb
[CLD-918] Added custom fields to Account class.
gmike11 May 18, 2020
8db4b19
Merge pull request #14 from CloudsnapInc/gmike11/CLD-918
gmike11 May 18, 2020
b3f65d1
[CLD-1157-expense-accounts-added]
reginad1 Sep 8, 2020
f61fd97
Merge pull request #15 from CloudsnapInc/CLD-1157-expense-accounts
reginad1 Sep 9, 2020
e27f858
[CLD-1220-service-purchase-item-endpoint]
reginad1 Sep 24, 2020
3b941d2
Merge pull request #16 from CloudsnapInc/CLD-1220-service-purchase-item
reginad1 Sep 24, 2020
c3145a6
CLD-1154 Improve error messaging
gmike11 Oct 6, 2020
805c7cd
Merge pull request #17 from CloudsnapInc/CLD-1154-error-messages
gmike11 Oct 16, 2020
a89db03
[CLD-1276-fix-typo]
reginad1 Oct 28, 2020
ccc3e31
Merge pull request #18 from CloudsnapInc/CLD-1279-fix-typo
reginad1 Oct 29, 2020
4251842
[CLD-1324-update-global-config]
reginad1 Nov 19, 2020
f73435d
Merge pull request #19 from CloudsnapInc/CLD-1324-update-global-config
reginad1 Nov 24, 2020
d410bee
[L3-39-add-accounting_period_fields]
dbbarkley Dec 17, 2020
489aa8b
Merge pull request #20 from CloudsnapInc/add_accounting_period_fields
dbbarkley Dec 17, 2020
cdc3e50
update readme to include Cloudsnap additions
reginad1 Jan 22, 2021
d74d3be
Merge pull request #21 from CloudsnapInc/update-readme
reginad1 Jan 25, 2021
67a0215
fix multiselect bug
dbbarkley Mar 5, 2021
a4460fe
Merge pull request #23 from CloudsnapInc/multi_select_support
dbbarkley Mar 9, 2021
4f0cc2c
added employee address records
dbbarkley Apr 7, 2021
1776652
Merge pull request #24 from CloudsnapInc/employee_address_support
dbbarkley Apr 8, 2021
1ac62f8
added default address field on employee class
jiminhuh Apr 13, 2021
f7fd347
Merge pull request #25 from CloudsnapInc/L3-199_adding_default_address
shaneblaser-cloudsnap Apr 13, 2021
6227de5
Initial commit WIP
gmike11 Jun 23, 2021
d8ff880
removed commented fields, using NullFieldList class
dbbarkley Jun 30, 2021
bb7f976
Why:
gmike11 Jul 13, 2021
ebb14df
Merge pull request #26 from CloudsnapInc/CLD-1835-netsuite-null-fields
gmike11 Jul 13, 2021
3643f51
return-netsuite-error-for-search-action-failures
Timothyjb Jul 28, 2021
3ede139
Merge pull request #27 from CloudsnapInc/return-netsuite-error-for-se…
shaneblaser-cloudsnap Jul 28, 2021
b6c885a
added missing fields and actions
Aug 9, 2021
18268f8
added tests
Aug 10, 2021
34b4bcb
Merge pull request #28 from CloudsnapInc/CLD_2049_Talend_use_cases
dbbarkley Aug 10, 2021
fc63299
CD-712-have-inventory_detail-use-the-InventoryDetail-class-in-vendor-…
Timothyjb Sep 8, 2021
fa48237
Merge pull request #29 from CloudsnapInc/CD-712-have-inventory_detail…
Timothyjb Sep 8, 2021
38d3e02
return-error-object-for-get-failure
Jan 24, 2022
cf7dd2c
Merge pull request #30 from CloudsnapInc/return-error-object-for-get-…
shaneblaser-cloudsnap Jan 24, 2022
e85ed1c
add-record-ItemOptionCustomField
Timothyjb Jan 27, 2022
d06a399
add-more-refs-to-custom-record-type
Timothyjb Feb 7, 2022
1a78dfb
Merge pull request #31 from CloudsnapInc/add-more-refs-to-custom-reco…
Timothyjb Feb 8, 2022
c5eaef0
updates-to-record-ref
Timothyjb Feb 11, 2022
13ff92b
Merge pull request #32 from CloudsnapInc/updates-to-record-ref
Timothyjb Feb 11, 2022
4f01669
add-more-attributes-to-TransactionColumnCustomField
Timothyjb Mar 14, 2022
29fbc98
Merge pull request #33 from CloudsnapInc/add-more-attributes-to-Trans…
Timothyjb Mar 15, 2022
e041094
CD-2148-add-custom-segments-class
Timothyjb Mar 17, 2022
19d9a09
Merge pull request #34 from CloudsnapInc/CD-2148-add-custom-segments-…
Timothyjb Mar 17, 2022
720d968
CD-2148-add-more-record_ref-for-TransactionColumnCustomField
Timothyjb Mar 17, 2022
7d28a32
Merge pull request #35 from CloudsnapInc/CD-2148-add-more-record_ref-…
shaneblaser-cloudsnap Mar 17, 2022
ae536df
CD-2148-return-warnings-for-GetSelectValue
Timothyjb Mar 17, 2022
9d97384
Merge pull request #36 from CloudsnapInc/CD-2148-return-warnings-for-…
Timothyjb Mar 17, 2022
cba0a8e
updates-to-get-list-action
Timothyjb Mar 21, 2022
4f45a81
Merge pull request #37 from CloudsnapInc/updates-to-get-list-action
Timothyjb Mar 21, 2022
5988707
additions-to-department
Timothyjb Apr 12, 2022
82aee86
Merge pull request #38 from CloudsnapInc/additions-to-department
shaneblaser-cloudsnap Apr 12, 2022
f330937
add-otherCustomField-record
Timothyjb Apr 14, 2022
64ae058
Merge pull request #39 from CloudsnapInc/add-otherCustomField-record
shaneblaser-cloudsnap Apr 14, 2022
fe26719
add-item-record-type
Timothyjb May 20, 2022
f976a83
Merge pull request #40 from CloudsnapInc/add-item-record-type
shaneblaser-cloudsnap May 20, 2022
7577b3c
fix-nme-Attributes-method
Timothyjb May 20, 2022
2de57c7
Merge pull request #41 from CloudsnapInc/fix-nme-Attributes-method
Timothyjb May 20, 2022
379328b
update-default-netsuite-api-version
Timothyjb Jul 18, 2022
1b62631
Merge pull request #42 from CloudsnapInc/update-default-netsuite-api-…
Timothyjb Jul 18, 2022
d8b8236
[CD-4491] Adding async add list action
gmike11 Mar 7, 2023
af6142b
Merge pull request #43 from CloudsnapInc/CD-4491-add-async-action
gmike11 Mar 7, 2023
818663d
Wrapping request body in array
gmike11 Mar 8, 2023
18ef911
small changes on async_add_list method
Mar 9, 2023
517d94f
Merge pull request #44 from CloudsnapInc/async_add_list_updates
dbbarkley Mar 9, 2023
f8c6667
Commenting out the code in the response_errors method
gmike11 Mar 10, 2023
ca563bd
Merge pull request #45 from CloudsnapInc/async-add-list-comment-out-r…
gmike11 Mar 10, 2023
05dc0cc
return raw response
gmike11 Mar 10, 2023
e7ffa2c
Merge pull request #46 from CloudsnapInc/async-add-list-return-raw-re…
gmike11 Mar 10, 2023
ce39546
commenting out parsing of response
gmike11 Mar 10, 2023
5136840
Merge pull request #47 from CloudsnapInc/comment-out-parsing-of-response
gmike11 Mar 10, 2023
6169b3e
making class variable
gmike11 Mar 10, 2023
d115ff1
Merge pull request #48 from CloudsnapInc/async-action-adding-at-sign
gmike11 Mar 10, 2023
718fd8b
Backing up a step
gmike11 Mar 10, 2023
789581f
Merge branch 'master' into async-action-acast-to-array
gmike11 Mar 10, 2023
9b2afac
Merge pull request #49 from CloudsnapInc/async-action-acast-to-array
gmike11 Mar 10, 2023
b60e4c0
commenting out response_errors
gmike11 Mar 10, 2023
16e7de3
Merge pull request #50 from CloudsnapInc/commenting-out-response_errors
gmike11 Mar 10, 2023
1248249
simplify responses
Mar 10, 2023
111ed8d
Merge pull request #51 from CloudsnapInc/remove-errors-on-async-add-list
dbbarkley Mar 10, 2023
1d138f0
[CD-4737] Upgraded gems to resolve security vulnerabilities
gmike11 Apr 11, 2023
d1f652e
Merge pull request #52 from CloudsnapInc/CD-4737-resolve-dependabot-a…
gmike11 Apr 11, 2023
4483487
update-default-version-to-2018
Timothyjb Jan 15, 2024
4e4e8e0
Merge pull request #53 from CloudsnapInc/update-default-version-to-2018
Timothyjb Jan 15, 2024
dd23ea9
CD-6394 add klass
tlepaylocity Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ gem 'simplecov', :require => false

gem 'pry-nav'
gem 'pry-rescue'
gem 'pry'

# optional dependency for more accurate timezone conversion
gem 'tzinfo', '1.2.5'
# gem 'tzinfo', '1.2.5'
# gem 'tzinfo', '2.0.0'
gem 'tzinfo', '>= 1.2.10'

# required for CircleCI to build properly with ruby 1.9.3
gem 'json', '~> 1.8.3'
gem 'rack', '~> 1.6.4'
# gem 'json', '~> 1.8.3'
# gem 'rack', '~> 1.6.4'
gem 'json', '>= 2.3.0'
gem 'rack', '>= 2.1.4'
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,23 @@ states.to_array.first[:get_all_response][:get_all_result][:record_list][:record]
# About SuiteSync

[SuiteSync, the Stripe-NetSuite integration](http://suitesync.io) uses this gem and funds the majority of it's development and maintenance.




# Cloudsnap Additions

I generally refer to the Netsuite Schema Browser as a source of truth over the actions, records, and fields that you see in this gem. That documentation can be found here: https://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2018_1/schema/record/account.html?mode=package

**One note is to be mindful of the version that you are looking at in the schema browser and the version that you are using when you configure the netsuite credentials.

### Actions
attach.rb--> lib/netsuite/actions/attach.rb
Based on the Netsuite Schema documentation, we added in the attach action functionality. This is primarily used to attach records considered File Cabinate


### Records
If you see the record in the netsuite schema browser, you can easily add it to the records in this gem. Use the fields and sub lists mentioned in the Netsuite schema browser to build out the record file following the same format as the other record files.

### Other Cloudsnap Changes
We made a few changes to the configuration.rb file. The check credentials method and set attributes methods were added to support the updated way of passing credentials. In the connection method, we also added the ability to set the wsdl and the endpoint level for the Savon client that is configured. This was required to connect to Netsuite api versions 2020+
21 changes: 21 additions & 0 deletions lib/netsuite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ module Support

module Actions
autoload :Add, 'netsuite/actions/add'
autoload :AsyncAddList, 'netsuite/actions/async_add_list'
autoload :Attach, 'netsuite/actions/attach'
autoload :Delete, 'netsuite/actions/delete'
autoload :DeleteList, 'netsuite/actions/delete_list'
autoload :Get, 'netsuite/actions/get'
Expand All @@ -74,6 +76,7 @@ module Records
autoload :Account, 'netsuite/records/account'
autoload :AccountingPeriod, 'netsuite/records/accounting_period'
autoload :Address, 'netsuite/records/address'
autoload :AttachBasicReference, 'netsuite/records/attach_basic_reference'
autoload :BaseRefList, 'netsuite/records/base_ref_list'
autoload :BillAddress, 'netsuite/records/bill_address'
autoload :BillingSchedule, 'netsuite/records/billing_schedule'
Expand Down Expand Up @@ -103,6 +106,7 @@ module Records
autoload :CustomField, 'netsuite/records/custom_field'
autoload :CustomFieldList, 'netsuite/records/custom_field_list'
autoload :CustomList, 'netsuite/records/custom_list'
autoload :CustomSegment, 'netsuite/records/custom_segment'
autoload :CustomRecord, 'netsuite/records/custom_record'
autoload :CustomRecordRef, 'netsuite/records/custom_record_ref'
autoload :CustomRecordType, 'netsuite/records/custom_record_type'
Expand Down Expand Up @@ -156,8 +160,16 @@ module Records
autoload :DescriptionItem, 'netsuite/records/description_item'
autoload :DiscountItem, 'netsuite/records/discount_item'
autoload :Duration, 'netsuite/records/duration'
autoload :EmployeeAddressbookList, 'netsuite/records/employee_addressbook_list'
autoload :EmployeeAddressbook, 'netsuite/records/employee_addressbook'
autoload :Employee, 'netsuite/records/employee'
autoload :EntityCustomField, 'netsuite/records/entity_custom_field'
autoload :ExpenseCategory, 'netsuite/records/expense_category'
autoload :ExpenseCategoryRate, 'netsuite/records/expense_category_rate'
autoload :ExpenseCategoryRatesList, 'netsuite/records/expense_category_rates_list'
autoload :ExpenseReport, 'netsuite/records/expense_report'
autoload :ExpenseReportExpense, 'netsuite/records/expense_report_expense'
autoload :ExpenseReportExpenseList, 'netsuite/records/expense_report_expense_list'
autoload :File, 'netsuite/records/file'
autoload :GiftCertificate, 'netsuite/records/gift_certificate'
autoload :GiftCertificateItem, 'netsuite/records/gift_certificate_item'
Expand Down Expand Up @@ -186,15 +198,19 @@ module Records
autoload :Invoice, 'netsuite/records/invoice'
autoload :InvoiceItem, 'netsuite/records/invoice_item'
autoload :InvoiceItemList, 'netsuite/records/invoice_item_list'
autoload :ItemOptionCustomField, 'netsuite/records/item_option_custom_field'
autoload :ItemFulfillment, 'netsuite/records/item_fulfillment'
autoload :ItemFulfillmentItem, 'netsuite/records/item_fulfillment_item'
autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list'
autoload :ItemFulfillmentPackage, 'netsuite/records/item_fulfillment_package'
autoload :ItemFulfillmentPackageList, 'netsuite/records/item_fulfillment_package_list'
autoload :Item, 'netsuite/records/item'
autoload :ItemGroup, 'netsuite/records/item_group'
autoload :ItemMember, 'netsuite/records/item_member'
autoload :ItemMemberList, 'netsuite/records/item_member_list'
autoload :ItemReceipt, 'netsuite/records/item_receipt'
autoload :ItemReceiptExpenseList, 'netsuite/records/item_receipt_expense_list'
autoload :ItemReceiptExpense, 'netsuite/records/item_receipt_expense'
autoload :ItemReceiptItemList, 'netsuite/records/item_receipt_item_list'
autoload :ItemReceiptItem, 'netsuite/records/item_receipt_item'
autoload :ItemVendor, 'netsuite/records/item_vendor'
Expand All @@ -217,10 +233,12 @@ module Records
autoload :NonInventoryResaleItem, 'netsuite/records/non_inventory_resale_item'
autoload :Note, 'netsuite/records/note'
autoload :NoteType, 'netsuite/records/note_type'
autoload :NullFieldList, 'netsuite/records/null_field_list'
autoload :Opportunity, 'netsuite/records/opportunity'
autoload :OpportunityItem, 'netsuite/records/opportunity_item'
autoload :OpportunityItemList, 'netsuite/records/opportunity_item_list'
autoload :OtherChargeSaleItem, 'netsuite/records/other_charge_sale_item'
autoload :OtherCustomField, 'netsuite/records/other_custom_field'
autoload :Partner, 'netsuite/records/partner'
autoload :PaymentItem, 'netsuite/records/payment_item'
autoload :PaymentMethod, 'netsuite/records/payment_method'
Expand All @@ -235,6 +253,8 @@ module Records
autoload :PromotionsList, 'netsuite/records/promotions_list'
autoload :Promotions, 'netsuite/records/promotions'
autoload :PurchaseOrder, 'netsuite/records/purchase_order'
autoload :PurchaseOrderExpenseList, 'netsuite/records/purchase_order_expense_list'
autoload :PurchaseOrderExpense, 'netsuite/records/purchase_order_expense'
autoload :PurchaseOrderItemList, 'netsuite/records/purchase_order_item_list'
autoload :PurchaseOrderItem, 'netsuite/records/purchase_order_item'
autoload :Roles, 'netsuite/records/roles'
Expand All @@ -252,6 +272,7 @@ module Records
autoload :SalesOrderItemList, 'netsuite/records/sales_order_item_list'
autoload :SalesRole, 'netsuite/records/sales_role'
autoload :SalesTaxItem, 'netsuite/records/sales_tax_item'
autoload :ServicePurchaseItem, 'netsuite/records/service_purchase_item'
autoload :ServiceResaleItem, 'netsuite/records/service_resale_item'
autoload :ServiceSaleItem, 'netsuite/records/service_sale_item'
autoload :SerializedAssemblyItem, 'netsuite/records/serialized_assembly_item'
Expand Down
3 changes: 1 addition & 2 deletions lib/netsuite/actions/add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@ def errors
module Support
def add(credentials={})
response = NetSuite::Actions::Add.call([self], credentials)

@errors = response.errors

if response.success?
@internal_id = response.body[:@internal_id]
@internal_id = response.body.dig(:@internal_id) unless response.body.class == Nori::StringIOFile
true
else
false
Expand Down
100 changes: 100 additions & 0 deletions lib/netsuite/actions/async_add_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/asyncAddList.html
module NetSuite
module Actions
class AsyncAddList
include Support::Requests

def initialize(*objects)
@objects = objects
end

private

def request(credentials={})
NetSuite::Configuration.connection(
{}, credentials
).call(:async_add_list, message: request_body)
end

# <soap:Body>
# <platformMsgs:asyncAddList>
# <platformMsgs:record xsi:type="listRel:Customer">
# <listRel:entityId>Shutter Fly</listRel:entityId>
# <listRel:companyName>Shutter Fly, Inc</listRel:companyName>
# </platformMsgs:record>
# <platformMsgs:record xsi:type="listRel:Customer">
# <listRel:entityId>Target</listRel:entityId>
# <listRel:companyName>Target</listRel:companyName>
# </platformMsgs:record>
# </platformMsgs:asyncAddList>
# </soap:Body>
def request_body
attrs = @objects.map do |o|
hash = o.to_record.merge({
'@xsi:type' => o.record_type
})

if o.respond_to?(:internal_id) && o.internal_id
hash['@internalId'] = o.internal_id
end

if o.respond_to?(:external_id) && o.external_id
hash['@externalId'] = o.external_id
end

hash
end

{ 'record' => attrs }
end

def response_hash
@response_hash ||= Array[@response.body[:async_add_list_response][:async_status_result]]
end

def response_body
@response_body ||= response_hash #.map { |h| h[:job_id] }
end

def response_errors
@response_errors ||= response_hash unless success?
# if response_hash[0].any? { |h| h[:status] && h[:status][:status_detail] }
# @response_errors ||= errors
# end
end

def errors
# errors = response_hash.select { |h| h[:status] && h[:status][:status_detail] }.map do |obj|
# error_obj = obj[:status][:status_detail]
# error_obj = [error_obj] if error_obj.class == Hash
# errors = error_obj.map do |error|
# NetSuite::Error.new(error)
# end

# [obj[:base_ref][:@external_id], errors]
# end
# Hash[errors]
end

def success?
!response_hash[0][:job_id].nil?
end

module Support
def async_add_list(credentials={})
response = NetSuite::Actions::AsyncAddList.call([self], credentials)
return response
# @errors = response.errors

# if response.success?
# response.body unless response.body.class == Nori::StringIOFile
# true
# else
# false
# end
end

end
end
end
end
87 changes: 87 additions & 0 deletions lib/netsuite/actions/attach.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
module NetSuite
module Actions
class Attach
include Support::Requests

attr_reader :response_hash

def initialize(object=nil)
@object = object
end

private

def request(credentials={})
NetSuite::Configuration.connection({}, credentials).call(:attach, :message => request_body)
end

#please note, reference is spelled referece and is documented that way in NetSuite's documentation
# <soap:Body>
# <platformMsgs:attach>
# <platformMsgs:attachReferece xsi:type="platformCore:AttachBasicReference">
# <platformCore:attachTo internalId="443" type="vendorBill" xsi:type="platformCore:RecordRef"/>
# <platformCore:attachedRecord type="file" internalId="353" xsi:type="platformCore:RecordRef"/>
# </platformMsgs:attachReferece>
# </platformMsgs:attach>
# </soap:Body>

def request_body
hash = {
'platformMsgs:attachReferece' => {
:content! => @object.to_record,
'@xsi:type' => @object.record_type
}
}
#not crazy about this solution but not sure how else to get the 'xsi:type' var in the hash
hash["platformMsgs:attachReferece"][:content!][:attributes!]["platformCore:attachTo"]["xsi:type"] = "platformCore:RecordRef"
hash["platformMsgs:attachReferece"][:content!][:attributes!]["platformCore:attachedRecord"]["xsi:type"] = "platformCore:RecordRef"

hash
end

def success?
@success ||= response_hash[:status][:@is_success] == 'true'
end

def response_body
@response_body ||= response_hash[:base_ref]
end

def response_errors
if response_hash[:status] && response_hash[:status][:status_detail]
@response_errors ||= errors
end
end

def response_hash
@response_hash ||= @response.to_hash[:attach_response][:write_response]
end

def errors
error_obj = response_hash[:status][:status_detail]
error_obj = [error_obj] if error_obj.class == Hash
error_obj.map do |error|
NetSuite::Error.new(error)
end
end


module Support
def attach(credentials={})
response = NetSuite::Actions::Attach.call([self], credentials)

@errors = response.errors

if response.success?
@internal_id = response.body[:@internal_id]
true
else
false
end
end
end


end
end
end
16 changes: 15 additions & 1 deletion lib/netsuite/actions/get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def response_hash
@response_hash = @response.body[:get_response][:read_response]
end

def response_errors
if response_hash[:status] && response_hash[:status][:status_detail]
@response_errors ||= errors
end
end

def errors
error_obj = response_hash.dig(:status,:status_detail)
OpenStruct.new(status: 404, status_detail: error_obj)
end

module Support

def self.included(base)
Expand All @@ -71,7 +82,10 @@ def get(options = {}, credentials = {})
if response.success?
new(response.body)
else
raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
NetSuite::Error.new(
code: response.errors.status_detail[:code],
message: response.errors.status_detail[:message]
)
end
end

Expand Down
Loading