Class: LedgerSync::Adaptors::NetSuiteSOAP::Adaptor

Inherits:
Adaptor
  • Object
show all
Defined in:
lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb

Constant Summary collapse

DEFAULT_API_VERSION =
'2016_2'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = 
  @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_idObject (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
end

#api_versionObject (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_keyObject (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_secretObject (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_idObject (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_secretObject (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_saveObject



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_gemString

Converts an account_id for use by the NetSuite gem

Returns:

  • (String)

    Converted account_id



38
39
40
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 38

def 
  .downcase.split('-sb').join('_SB')
end

#account_id_for_urlString

Converts an account_id for use in the API URL

Returns:

  • (String)

    API URL compliant account_id



47
48
49
# File 'lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb', line 47

def 
  .downcase.split('_SB').join('-sb')
end

#setupObject



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_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!

     
    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 "#{}.suitetalk.api.netsuite.com"
  end
end

#teardownObject



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_performObject



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