Class: LedgerSync::Adaptors::NetSuite::Adaptor
- Inherits:
-
Adaptor
- Object
- Adaptor
- LedgerSync::Adaptors::NetSuite::Adaptor
show all
- Defined in:
- lib/ledger_sync/adaptors/netsuite/adaptor.rb
Constant Summary
collapse
{
}.freeze
{
'Accept' => '*/*',
'Content-Type' => 'application/json'
}.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
#valid?, #validate, #validate_or_fail
Constructor Details
#initialize(account_id:, consumer_key:, consumer_secret:, token_id:, token_secret:) ⇒ Adaptor
Returns a new instance of Adaptor.
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 24
def initialize(
account_id:,
consumer_key:,
consumer_secret:,
token_id:,
token_secret:
)
@account_id = account_id
@consumer_key = consumer_key
@consumer_secret = consumer_secret
@token_id = token_id
@token_secret = token_secret
end
|
Instance Attribute Details
#account_id ⇒ Object
Returns the value of attribute account_id.
18
19
20
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 18
def account_id
@account_id
end
|
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
18
19
20
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 18
def consumer_key
@consumer_key
end
|
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
18
19
20
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 18
def consumer_secret
@consumer_secret
end
|
#token_id ⇒ Object
Returns the value of attribute token_id.
18
19
20
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 18
def token_id
@token_id
end
|
#token_secret ⇒ Object
Returns the value of attribute token_secret.
18
19
20
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 18
def token_secret
@token_secret
end
|
Class Method Details
.ledger_attributes_to_save ⇒ Object
80
81
82
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 80
def self.ledger_attributes_to_save
%i[]
end
|
.new_from_env(**override) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 84
def self.new_from_env(**override)
new(
{
account_id: ENV.fetch('NETSUITE_ACCOUNT_ID', nil),
consumer_key: ENV.fetch('NETSUITE_CONSUMER_KEY', nil),
consumer_secret: ENV.fetch('NETSUITE_CONSUMER_SECRET', nil),
token_id: ENV.fetch('NETSUITE_TOKEN_ID', nil),
token_secret: ENV.fetch('NETSUITE_TOKEN_SECRET', nil)
}.merge(override)
)
end
|
Instance Method Details
#account_id_for_oauth ⇒ Object
38
39
40
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 38
def account_id_for_oauth
account_id.split('-sb').join('_SB')
end
|
#account_id_for_url ⇒ Object
42
43
44
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 42
def account_id_for_url
account_id.split('_SB').join('-sb')
end
|
#api_base_url ⇒ Object
46
47
48
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 46
def api_base_url
@api_base_url ||= "https://#{api_host}/rest/platform/v1"
end
|
#api_host ⇒ Object
50
51
52
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 50
def api_host
@api_host ||= "#{account_id_for_url}.suitetalk.api.netsuite.com"
end
|
#delete(**keywords) ⇒ Object
54
55
56
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 54
def delete(**keywords)
request(keywords.merge(method: :delete))
end
|
#get(**keywords) ⇒ Object
58
59
60
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 58
def get(**keywords)
request(keywords.merge(method: :get))
end
|
#patch(headers: {}, **keywords) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 62
def patch(headers: {}, **keywords)
request(
keywords.merge(
headers: WRITE_HEADERS.merge(),
method: :patch
)
)
end
|
#post(headers: {}, **keywords) ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/ledger_sync/adaptors/netsuite/adaptor.rb', line 71
def post(headers: {}, **keywords)
request(
keywords.merge(
headers: WRITE_HEADERS.merge(),
method: :post
)
)
end
|