Class: LedgerSync::Adaptors::NetSuiteSOAP::Adaptor
- Defined in:
- lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb
Constant Summary collapse
- DEFAULT_API_VERSION =
'2016_2'.freeze
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#consumer_key ⇒ Object
readonly
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
readonly
Returns the value of attribute consumer_secret.
-
#token_id ⇒ Object
readonly
Returns the value of attribute token_id.
-
#token_secret ⇒ Object
readonly
Returns the value of attribute token_secret.
Class Method Summary collapse
Instance Method Summary collapse
-
#account_id_for_gem ⇒ String
Converts an account_id for use by the NetSuite gem.
-
#account_id_for_url ⇒ String
Converts an account_id for use in the API URL.
-
#initialize(account_id:, api_version: nil, consumer_key:, consumer_secret:, token_id:, token_secret:) ⇒ Adaptor
constructor
A new instance of Adaptor.
- #setup ⇒ Object
- #teardown ⇒ Object
- #wrap_perform ⇒ Object
Methods inherited from Adaptor
#adaptor_configuration, #base_module, base_module, base_operation_module_for, config, #ledger_attributes_to_save, #parse_operation_error, #searcher_for?, #searcher_klass_for, #url_for, url_for
Methods included from Validatable
#valid?, #validate, #validate_or_fail
Constructor Details
#initialize(account_id:, api_version: nil, consumer_key:, consumer_secret:, token_id:, token_secret:) ⇒ Adaptor
Returns a new instance of Adaptor.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 17 def initialize( account_id:, api_version: nil, consumer_key:, consumer_secret:, token_id:, token_secret: ) @account_id = account_id @api_version = api_version || DEFAULT_API_VERSION @consumer_key = consumer_key @consumer_secret = consumer_secret @token_id = token_id @token_secret = token_secret end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
9 10 11 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 9 def account_id @account_id end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
9 10 11 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 9 def api_version @api_version end |
#consumer_key ⇒ Object (readonly)
Returns the value of attribute consumer_key.
9 10 11 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 9 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object (readonly)
Returns the value of attribute consumer_secret.
9 10 11 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 9 def consumer_secret @consumer_secret end |
#token_id ⇒ Object (readonly)
Returns the value of attribute token_id.
9 10 11 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 9 def token_id @token_id end |
#token_secret ⇒ Object (readonly)
Returns the value of attribute token_secret.
9 10 11 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 9 def token_secret @token_secret end |
Class Method Details
.ledger_attributes_to_save ⇒ Object
86 87 88 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 86 def self.ledger_attributes_to_save [] end |
Instance Method Details
#account_id_for_gem ⇒ String
Converts an account_id for use by the NetSuite gem
38 39 40 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 38 def account_id_for_gem account_id.downcase.split('-sb').join('_SB') end |
#account_id_for_url ⇒ String
Converts an account_id for use in the API URL
47 48 49 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 47 def account_id_for_url account_id.downcase.split('_SB').join('-sb') end |
#setup ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 51 def setup setup_account_id_for_gem = account_id_for_gem setup_account_id_for_url = account_id_for_url setup_api_version = api_version setup_consumer_key = consumer_key setup_consumer_secret = consumer_secret setup_token_id = token_id setup_token_secret = token_secret ::NetSuite.configure do reset! account setup_account_id_for_gem consumer_key setup_consumer_key consumer_secret setup_consumer_secret token_id setup_token_id token_secret setup_token_secret api_version setup_api_version wsdl_domain "#{setup_account_id_for_url}.suitetalk.api.netsuite.com" end end |
#teardown ⇒ Object
73 74 75 76 77 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 73 def teardown ::NetSuite.configure do reset! end end |
#wrap_perform ⇒ Object
79 80 81 82 83 84 |
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 79 def wrap_perform setup yield ensure teardown end |