netsuite_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +79 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/netsuite_api/base.rb +98 -0
- data/lib/netsuite_api/concerns/request_handler.rb +31 -0
- data/lib/netsuite_api/concerns/response_handler.rb +43 -0
- data/lib/netsuite_api/contact.rb +12 -0
- data/lib/netsuite_api/credit_memo.rb +17 -0
- data/lib/netsuite_api/customer.rb +12 -0
- data/lib/netsuite_api/invoice.rb +24 -0
- data/lib/netsuite_api/payment.rb +24 -0
- data/lib/netsuite_api/vendor.rb +12 -0
- data/lib/netsuite_api/vendor_bill.rb +12 -0
- data/lib/netsuite_api/version.rb +3 -0
- data/lib/netsuite_api.rb +20 -0
- data/netsuite_api.gemspec +45 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9109cab50de3927273c1731c05df000ce68b4269f8c8e23fc8b3518978a44a59
|
4
|
+
data.tar.gz: c20fd911f0e219b9b3f7609500ca5f67d1c87a2d36730ec6786c53c2cfe27e7d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 610dc43e109bbda0ffc6aaeb18e2a5b9b3a3338403e486233d5683642518cf1318d4ff0eb707879677b1be51b242c0b9665fa3fb0415b41d469f2b33c94a6164
|
7
|
+
data.tar.gz: 11cc8457fbeee991b553f619649c9ac7f49afe7572787d01a619c231cb732d7b5e6f048471a7bca7b07cf134c6c5c654a130c51f2e781b8c62dfacaee2bd09f7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
netsuite_api (0.1.0)
|
5
|
+
activesupport (~> 6.0)
|
6
|
+
faraday (~> 2.0)
|
7
|
+
securerandom (~> 0.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.1.7.10)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
addressable (2.8.7)
|
19
|
+
public_suffix (>= 2.0.2, < 7.0)
|
20
|
+
base64 (0.2.0)
|
21
|
+
bigdecimal (3.1.8)
|
22
|
+
coderay (1.1.3)
|
23
|
+
concurrent-ruby (1.3.4)
|
24
|
+
crack (1.0.0)
|
25
|
+
bigdecimal
|
26
|
+
rexml
|
27
|
+
diff-lcs (1.5.1)
|
28
|
+
faraday (2.8.1)
|
29
|
+
base64
|
30
|
+
faraday-net_http (>= 2.0, < 3.1)
|
31
|
+
ruby2_keywords (>= 0.0.4)
|
32
|
+
faraday-net_http (3.0.2)
|
33
|
+
hashdiff (1.1.1)
|
34
|
+
i18n (1.14.6)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
method_source (1.1.0)
|
37
|
+
minitest (5.25.1)
|
38
|
+
pry (0.14.2)
|
39
|
+
coderay (~> 1.1)
|
40
|
+
method_source (~> 1.0)
|
41
|
+
public_suffix (5.1.1)
|
42
|
+
rake (10.5.0)
|
43
|
+
rexml (3.3.9)
|
44
|
+
rspec (3.13.0)
|
45
|
+
rspec-core (~> 3.13.0)
|
46
|
+
rspec-expectations (~> 3.13.0)
|
47
|
+
rspec-mocks (~> 3.13.0)
|
48
|
+
rspec-core (3.13.2)
|
49
|
+
rspec-support (~> 3.13.0)
|
50
|
+
rspec-expectations (3.13.3)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.13.0)
|
53
|
+
rspec-mocks (3.13.2)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.13.0)
|
56
|
+
rspec-support (3.13.1)
|
57
|
+
ruby2_keywords (0.0.5)
|
58
|
+
securerandom (0.3.1)
|
59
|
+
tzinfo (2.0.6)
|
60
|
+
concurrent-ruby (~> 1.0)
|
61
|
+
webmock (3.24.0)
|
62
|
+
addressable (>= 2.8.0)
|
63
|
+
crack (>= 0.3.2)
|
64
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
65
|
+
zeitwerk (2.6.18)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
ruby
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
bundler (~> 1.17)
|
72
|
+
netsuite_api!
|
73
|
+
pry
|
74
|
+
rake (~> 10.0)
|
75
|
+
rspec (~> 3.0)
|
76
|
+
webmock (~> 3.0)
|
77
|
+
|
78
|
+
BUNDLED WITH
|
79
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# NetsuiteApi
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/netsuite_api`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'netsuite_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install netsuite_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/netsuite_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the NetsuiteApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/netsuite_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "netsuite_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'securerandom'
|
3
|
+
require 'active_support/core_ext/object'
|
4
|
+
require "pry"
|
5
|
+
|
6
|
+
module NetsuiteApi
|
7
|
+
class Base
|
8
|
+
attr_reader :netsuite_host, :account_id, :consumer_key, :token
|
9
|
+
|
10
|
+
def initialize(netsuite_host: nil, netsuite_pdf_host: nil, account_id: nil, consumer_key: nil, token: nil, token_secret: nil, consumer_secret: nil)
|
11
|
+
@netsuite_host = netsuite_host || ENV['NETSUITE_HOST']
|
12
|
+
@netsuite_pdf_host = netsuite_pdf_host || ENV['NETSUITE_PDF_HOST']
|
13
|
+
@account_id = account_id || ENV['NETSUITE_ACCOUNT_ID']
|
14
|
+
@consumer_key = consumer_key || ENV['NETSUITE_CONSUMER_KEY']
|
15
|
+
@token = token || ENV['NETSUITE_TOKEN_ID']
|
16
|
+
@token_secret = token_secret || ENV['NETSUITE_TOKEN']
|
17
|
+
@consumer_secret = consumer_secret || ENV['NETSUITE_CONSUMER_SECRET']
|
18
|
+
end
|
19
|
+
|
20
|
+
def request(url, query_params: nil, host_type: :netsuite_host, body: nil, method: :get, headers: {})
|
21
|
+
host = host_options[host_type]
|
22
|
+
connection(host).send(method) do |req|
|
23
|
+
req.url full_url(url, query_params)
|
24
|
+
req.headers["Authorization"] = authorization_header(url, method, query_params, host: host)
|
25
|
+
req.headers["Content-Type"] = "application/json"
|
26
|
+
req.headers.merge!(headers)
|
27
|
+
req.body = JSON.dump(body) if body
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def connection(host)
|
34
|
+
conn = Faraday.new(url: host) do |faraday|
|
35
|
+
faraday.adapter Faraday.default_adapter
|
36
|
+
faraday.ssl.verify = true # You can set this to false if you have SSL verification issues
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def host_options
|
41
|
+
{ netsuite_host: @netsuite_host, netsuite_pdf_host: @netsuite_pdf_host }
|
42
|
+
end
|
43
|
+
|
44
|
+
def authorization_header(url, method, query_params, host:)
|
45
|
+
"OAuth realm=\"#{account_id}\",oauth_consumer_key=\"#{consumer_key}\",oauth_token=\"#{token}\",oauth_signature_method=\"HMAC-SHA256\",oauth_timestamp=\"#{oauth_timestamp}\",oauth_nonce=\"#{oauth_nonce}\",oauth_version=\"1.0\",oauth_signature=\"#{generate_oauth_signature(url, method, query_params, host: host)}\""
|
46
|
+
end
|
47
|
+
|
48
|
+
def oauth_nonce
|
49
|
+
@oauth_nonce = SecureRandom.hex(16)
|
50
|
+
end
|
51
|
+
|
52
|
+
def oauth_timestamp
|
53
|
+
@oauth_timestamp = Time.now.to_i
|
54
|
+
end
|
55
|
+
|
56
|
+
def full_url(url, query_params)
|
57
|
+
if query_params
|
58
|
+
"#{url}?#{query_params.to_query}"
|
59
|
+
else
|
60
|
+
url
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def url_encode(url)
|
65
|
+
CGI.escape(url)
|
66
|
+
end
|
67
|
+
|
68
|
+
def generate_oauth_signature(url, http_method, query_params, host:)
|
69
|
+
# Step 1: Combine parameters
|
70
|
+
all_params = {
|
71
|
+
'oauth_consumer_key' => consumer_key,
|
72
|
+
'oauth_token' => token,
|
73
|
+
'oauth_signature_method' => 'HMAC-SHA256',
|
74
|
+
'oauth_timestamp' => @oauth_timestamp,
|
75
|
+
'oauth_nonce' => @oauth_nonce, # Generate a random nonce
|
76
|
+
'oauth_version' => '1.0'
|
77
|
+
}
|
78
|
+
all_params.merge!(query_params) if query_params
|
79
|
+
|
80
|
+
# Step 2: Normalize parameters
|
81
|
+
normalized_params = all_params.sort.map { |k, v| url_encode("#{k}=#{URI.encode_www_form_component(v).gsub('+', '%20')}") }.join('%26')
|
82
|
+
|
83
|
+
# Step 3: Generate Signature Base String (SBS)
|
84
|
+
sbs = "#{http_method.to_s.upcase}&#{url_encode("#{host}#{url}")}&#{normalized_params}"
|
85
|
+
|
86
|
+
# Step 4: Generate Signing Key
|
87
|
+
signing_key = "#{@consumer_secret}&#{@token_secret}"
|
88
|
+
|
89
|
+
# Step 5: Sign the Signature Base String
|
90
|
+
digest = OpenSSL::Digest.new('sha256')
|
91
|
+
hmac = OpenSSL::HMAC.digest(digest, signing_key, sbs)
|
92
|
+
|
93
|
+
oauth_signature = CGI.escape(Base64.encode64(hmac).chomp.gsub('\n', ''))
|
94
|
+
|
95
|
+
oauth_signature
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module NetsuiteApi
|
2
|
+
module Concerns
|
3
|
+
module RequestHandler
|
4
|
+
|
5
|
+
def get(id, query_params: nil)
|
6
|
+
response = request("#{self.class::PATH}/#{id}", query_params: query_params, host_type: :netsuite_host)
|
7
|
+
get_response_handler(response)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(body)
|
11
|
+
response = request("#{self.class::PATH}", body: body, method: :post, host_type: :netsuite_host)
|
12
|
+
post_and_patch_response_handler(response)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(id, body, query_params: nil)
|
16
|
+
response = request("#{self.class::PATH}/#{id}", body: body, method: :patch, host_type: :netsuite_host)
|
17
|
+
post_and_patch_response_handler(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(id)
|
21
|
+
response = request("#{self.class::PATH}/#{id}", method: :delete, host_type: :netsuite_host)
|
22
|
+
delete_response_handler(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
def query(query)
|
26
|
+
response = request("#{self.class::PATH}", query_params: query, host_type: :netsuite_host)
|
27
|
+
get_response_handler(response)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module NetsuiteApi
|
2
|
+
module Concerns
|
3
|
+
module ResponseHandler
|
4
|
+
class NetSuiteApiError < StandardError
|
5
|
+
attr_reader :title, :details
|
6
|
+
def initialize(msg, title, details)
|
7
|
+
@title = title
|
8
|
+
@details = details
|
9
|
+
super(msg)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_response_handler(response)
|
14
|
+
if response.success?
|
15
|
+
JSON.parse(response.body)
|
16
|
+
else
|
17
|
+
error_handler(response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def post_and_patch_response_handler(response)
|
22
|
+
if response.success?
|
23
|
+
response.headers["location"].split('/').last
|
24
|
+
else
|
25
|
+
error_handler(response)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete_response_handler(response)
|
30
|
+
if response.success?
|
31
|
+
true
|
32
|
+
else
|
33
|
+
error_handler(response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def error_handler(response)
|
38
|
+
response_body = JSON.parse(response.body)
|
39
|
+
raise NetSuiteApiError.new(response_body["title"], response_body["title"], response_body["o:errorDetails"])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class Contact < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "contact"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class CreditMemo < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "creditMemo"
|
11
|
+
|
12
|
+
def create(invoice_id, params)
|
13
|
+
response = request("invoice/#{invoice_id}/!transform/#{PATH}", body: params, method: :post, host_type: :netsuite_host)
|
14
|
+
post_and_patch_response_handler(response)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class Customer < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "customer"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class Invoice < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "invoice"
|
11
|
+
|
12
|
+
def get_pdf(query)
|
13
|
+
path = "app/site/hosting/restlet.nl"
|
14
|
+
response = request(path, query_params: query, host_type: :netsuite_pdf_host)
|
15
|
+
|
16
|
+
if response.success?
|
17
|
+
ecrypted_str = JSON.parse(response.body).dig('data64')
|
18
|
+
plain = Base64.decode64(ecrypted_str)
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class Payment < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "customerpayment"
|
11
|
+
|
12
|
+
def get_pdf(query)
|
13
|
+
path = "app/site/hosting/restlet.nl"
|
14
|
+
response = request(path, query_params: query, host_type: :netsuite_pdf_host)
|
15
|
+
|
16
|
+
if response.success?
|
17
|
+
ecrypted_str = JSON.parse(response.body).dig('data64')
|
18
|
+
plain = Base64.decode64(ecrypted_str)
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class Vendor < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "vendor"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'netsuite_api/base'
|
2
|
+
require 'netsuite_api/concerns/request_handler'
|
3
|
+
require 'netsuite_api/concerns/response_handler'
|
4
|
+
|
5
|
+
module NetsuiteApi
|
6
|
+
class VendorBill < Base
|
7
|
+
include Concerns::RequestHandler
|
8
|
+
include Concerns::ResponseHandler
|
9
|
+
|
10
|
+
PATH = "vendorBill"
|
11
|
+
end
|
12
|
+
end
|
data/lib/netsuite_api.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "netsuite_api/version"
|
2
|
+
require "netsuite_api/invoice"
|
3
|
+
require "netsuite_api/credit_memo"
|
4
|
+
require "netsuite_api/customer"
|
5
|
+
require "netsuite_api/contact"
|
6
|
+
require "netsuite_api/payment"
|
7
|
+
require "netsuite_api/vendor"
|
8
|
+
require "netsuite_api/vendor_bill"
|
9
|
+
require "pry"
|
10
|
+
|
11
|
+
module NetsuiteApi
|
12
|
+
# class Error < StandardError; end
|
13
|
+
# Your code goes here...
|
14
|
+
|
15
|
+
def self.hi
|
16
|
+
"Hello World!"
|
17
|
+
# binding.pry
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "netsuite_api/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "netsuite_api"
|
8
|
+
spec.version = NetsuiteApi::VERSION
|
9
|
+
spec.authors = ["HueiYi Lucy Cheng"]
|
10
|
+
spec.email = ["iceland101113@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby Library for NetSuite REST API.}
|
13
|
+
spec.description = %q{Ruby Library for NetSuite REST API. Originally developed by HueiYi Lucy Cheng.}
|
14
|
+
spec.homepage = "https://github.com/iceland101113/netsuite_api"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/iceland101113/netsuite_api"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/iceland101113/netsuite_api"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
spec.add_development_dependency "pry"
|
41
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
42
|
+
spec.add_dependency "faraday", "~> 2.0"
|
43
|
+
spec.add_dependency "activesupport", "~> 6.0"
|
44
|
+
spec.add_dependency "securerandom", "~> 0.3"
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: netsuite_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- HueiYi Lucy Cheng
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '6.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '6.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: securerandom
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.3'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.3'
|
125
|
+
description: Ruby Library for NetSuite REST API. Originally developed by HueiYi Lucy
|
126
|
+
Cheng.
|
127
|
+
email:
|
128
|
+
- iceland101113@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CODE_OF_CONDUCT.md
|
137
|
+
- Gemfile
|
138
|
+
- Gemfile.lock
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- lib/netsuite_api.rb
|
145
|
+
- lib/netsuite_api/base.rb
|
146
|
+
- lib/netsuite_api/concerns/request_handler.rb
|
147
|
+
- lib/netsuite_api/concerns/response_handler.rb
|
148
|
+
- lib/netsuite_api/contact.rb
|
149
|
+
- lib/netsuite_api/credit_memo.rb
|
150
|
+
- lib/netsuite_api/customer.rb
|
151
|
+
- lib/netsuite_api/invoice.rb
|
152
|
+
- lib/netsuite_api/payment.rb
|
153
|
+
- lib/netsuite_api/vendor.rb
|
154
|
+
- lib/netsuite_api/vendor_bill.rb
|
155
|
+
- lib/netsuite_api/version.rb
|
156
|
+
- netsuite_api.gemspec
|
157
|
+
homepage: https://github.com/iceland101113/netsuite_api
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata:
|
161
|
+
homepage_uri: https://github.com/iceland101113/netsuite_api
|
162
|
+
source_code_uri: https://github.com/iceland101113/netsuite_api
|
163
|
+
changelog_uri: https://github.com/iceland101113/netsuite_api
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubygems_version: 3.0.3.1
|
180
|
+
signing_key:
|
181
|
+
specification_version: 4
|
182
|
+
summary: Ruby Library for NetSuite REST API.
|
183
|
+
test_files: []
|