finale 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/finale.rb +36 -12
- data/lib/finale/order.rb +3 -8
- data/lib/finale/shipment.rb +1 -7
- data/lib/finale/version.rb +1 -1
- metadata +46 -14
- data/.gitignore +0 -15
- data/.rspec +0 -2
- data/.travis.yml +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/finale.gemspec +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c2549196c2c78881f1fdc2b48e0da4552a7821f
|
4
|
+
data.tar.gz: a90de795f5c19f9de201081657f8b8bf77009fbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3431646ac3855e4b8e48f19695d8e9b14a9e1733cc58f5428e643b741ca0d5da63af40765d4a7755184c39aeac1f256cda238f1c0349b3a6ce3c2f8466dc4b82
|
7
|
+
data.tar.gz: 452f6d2b5ade9bbb2f3751b40f8e6cfe362c03f7c1ea47959293d25128751dbd76bf7a340e9870a20816f3c8a482a8546fde72ecf15e03ef7fdd40bf23dcbd7d
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[![Version ](https://img.shields.io/gem/v/finale.svg?maxAge=2592000)](https://rubygems.org/gems/finale)
|
2
|
+
[![Build Status ](https://travis-ci.org/popp0102/finale.svg)](https://travis-ci.org/popp0102/finale)
|
3
|
+
[![Code Climate ](https://api.codeclimate.com/v1/badges/7c7d7c83bde6c288f5e8/maintainability)](https://codeclimate.com/github/popp0102/finale/maintainability)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/popp0102/finale/badges/coverage.svg)](https://codeclimate.com/github/popp0102/finale/coverage)
|
5
|
+
|
1
6
|
# Finale
|
2
7
|
|
3
8
|
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/finale`. To experiment with that code, run `bin/console` for an interactive prompt.
|
data/lib/finale.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require "rest-client"
|
2
|
+
require "json"
|
3
|
+
require "base64"
|
4
|
+
require "active_support/all"
|
2
5
|
|
3
6
|
require "finale/version"
|
4
7
|
require "finale/errors"
|
@@ -10,10 +13,10 @@ module Finale
|
|
10
13
|
MAX_REQUESTS = 100 # Finale API Usage: 'https://support.finaleinventory.com/hc/en-us/articles/115007830648-Getting-Started'
|
11
14
|
BASE_URL = 'https://app.finaleinventory.com'
|
12
15
|
|
13
|
-
def initialize(
|
16
|
+
def initialize(account)
|
14
17
|
@cookies = nil
|
15
18
|
@request_count = 0
|
16
|
-
@
|
19
|
+
@account = account
|
17
20
|
@login_url = construct_url(:auth)
|
18
21
|
@order_url = construct_url(:order)
|
19
22
|
@shipment_url = construct_url(:shipment)
|
@@ -28,19 +31,20 @@ module Finale
|
|
28
31
|
request(verb: :LOGIN, payload: payload)
|
29
32
|
end
|
30
33
|
|
31
|
-
def get_order_ids
|
32
|
-
body = request(verb: :GET, url: @order_url)
|
33
|
-
order_ids = body[:orderId]
|
34
|
-
order_ids.map(&:to_i).sort.uniq
|
35
|
-
end
|
36
|
-
|
37
34
|
def get_order(id)
|
38
35
|
response = request(verb: :GET, url: "#{@order_url}/#{id}")
|
39
36
|
Order.new(response)
|
40
37
|
end
|
41
38
|
|
39
|
+
def get_orders(filter: nil)
|
40
|
+
resp_orders = request(verb: :GET, url: @order_url, filter: filter )
|
41
|
+
rows = column_major_to_row_major(resp_orders)
|
42
|
+
orders = rows.map { |r| Order.new(r) }
|
43
|
+
orders
|
44
|
+
end
|
45
|
+
|
42
46
|
def get_shipments(order)
|
43
|
-
order.
|
47
|
+
order.shipmentUrlList.map do |suffix_url|
|
44
48
|
url = "#{BASE_URL}#{suffix_url}"
|
45
49
|
response = request(verb: :GET, url: url)
|
46
50
|
Shipment.new(response)
|
@@ -49,11 +53,24 @@ module Finale
|
|
49
53
|
|
50
54
|
private
|
51
55
|
|
56
|
+
def column_major_to_row_major(column_major)
|
57
|
+
row_major = []
|
58
|
+
keys = column_major.keys
|
59
|
+
values = column_major.values || [[]]
|
60
|
+
num_cols = values.count == 0 ? 0 : values.first.count
|
61
|
+
num_cols.times do
|
62
|
+
rowvals = keys.map { |key| column_major[key].shift }
|
63
|
+
row = Hash[keys.zip(rowvals)]
|
64
|
+
row_major << row
|
65
|
+
end
|
66
|
+
row_major
|
67
|
+
end
|
68
|
+
|
52
69
|
def construct_url(resource)
|
53
|
-
"#{BASE_URL}/#{@
|
70
|
+
"#{BASE_URL}/#{@account}/api/#{resource}"
|
54
71
|
end
|
55
72
|
|
56
|
-
def request(verb: nil, url: nil, payload: nil)
|
73
|
+
def request(verb: nil, url: nil, payload: nil, filter: nil)
|
57
74
|
raise MaxRequests.new(MAX_REQUESTS) if @request_count >= MAX_REQUESTS
|
58
75
|
raise NotLoggedIn.new(verb: verb, url: url) unless verb == :LOGIN || !@cookies.nil?
|
59
76
|
|
@@ -62,7 +79,14 @@ module Finale
|
|
62
79
|
response = RestClient.post(@login_url, payload)
|
63
80
|
@cookies = response.cookies
|
64
81
|
when :GET
|
65
|
-
|
82
|
+
params = {}
|
83
|
+
|
84
|
+
if filter.present?
|
85
|
+
encoded_filter = Base64.encode64(filter.to_json)
|
86
|
+
params.merge!(filter: encoded_filter)
|
87
|
+
end
|
88
|
+
|
89
|
+
response = RestClient.get(url, cookies: @cookies, params: params)
|
66
90
|
when :POST
|
67
91
|
response = RestClient.post(url, cookies: @cookies)
|
68
92
|
end
|
data/lib/finale/order.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
|
2
|
-
class Order
|
3
|
-
attr_reader :id, :shipment_urls, :source
|
1
|
+
require 'ostruct'
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
@shipment_urls = order_response[:shipmentUrlList]
|
8
|
-
@source = order_response[:saleSourceId]
|
9
|
-
end
|
3
|
+
module Finale
|
4
|
+
class Order < OpenStruct
|
10
5
|
end
|
11
6
|
end
|
12
7
|
|
data/lib/finale/shipment.rb
CHANGED
data/lib/finale/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Jason Poppler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rest-client
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.2'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: bundler
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,24 +136,28 @@ dependencies:
|
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '4.10'
|
111
|
-
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.16'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.16'
|
153
|
+
description:
|
112
154
|
email:
|
113
155
|
- popp0102@getnotion.com
|
114
156
|
executables: []
|
115
157
|
extensions: []
|
116
158
|
extra_rdoc_files: []
|
117
159
|
files:
|
118
|
-
- ".gitignore"
|
119
|
-
- ".rspec"
|
120
|
-
- ".travis.yml"
|
121
|
-
- CODE_OF_CONDUCT.md
|
122
|
-
- Gemfile
|
123
|
-
- LICENSE.txt
|
124
160
|
- README.md
|
125
|
-
- Rakefile
|
126
|
-
- bin/console
|
127
|
-
- bin/setup
|
128
|
-
- finale.gemspec
|
129
161
|
- lib/finale.rb
|
130
162
|
- lib/finale/errors.rb
|
131
163
|
- lib/finale/order.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
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 jason@getnotion.com. 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
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2018 jpoppler
|
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/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "finale"
|
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
DELETED
data/finale.gemspec
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "finale/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "finale"
|
8
|
-
spec.version = Finale::VERSION
|
9
|
-
spec.authors = ["popp0102"]
|
10
|
-
spec.email = ["popp0102@getnotion.com"]
|
11
|
-
|
12
|
-
spec.summary = 'A client to interact with the Finale Inventory System.'
|
13
|
-
spec.description = 'A client to interact with the Finale Inventory System.'
|
14
|
-
spec.homepage = "https://github.com/popp0102/finale"
|
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["allowed_push_host"] = "https://rubygems.org"
|
21
|
-
else
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
-
"public gem pushes."
|
24
|
-
end
|
25
|
-
|
26
|
-
# Specify which files should be added to the gem when it is released.
|
27
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
-
end
|
31
|
-
spec.bindir = "exe"
|
32
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
-
spec.require_paths = ["lib"]
|
34
|
-
|
35
|
-
spec.add_runtime_dependency "rest-client", "~> 2.0"
|
36
|
-
|
37
|
-
spec.add_development_dependency "bundler", "~> 1.16"
|
38
|
-
spec.add_development_dependency "webmock", "~> 3.4"
|
39
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
-
spec.add_development_dependency 'pry-byebug', '~> 3'
|
42
|
-
spec.add_development_dependency "factory_bot", "~> 4.10"
|
43
|
-
end
|