vizion 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.org +112 -0
- data/bin/console +2 -0
- data/docs/index.html +426 -0
- data/docs/style.css +91 -0
- data/lib/vizion/client.rb +22 -18
- data/lib/vizion/collection.rb +29 -0
- data/lib/vizion/error.rb +3 -0
- data/lib/vizion/object.rb +18 -0
- data/lib/vizion/objects/carrier.rb +4 -0
- data/lib/vizion/objects/reference.rb +4 -0
- data/lib/vizion/resource.rb +47 -0
- data/lib/vizion/resources/carriers.rb +9 -0
- data/lib/vizion/resources/references.rb +27 -0
- data/lib/vizion/version.rb +1 -1
- data/lib/vizion.rb +12 -5
- data/vizion.gemspec +5 -8
- metadata +24 -45
- data/README.md +0 -85
- data/lib/vizion/client/carriers.rb +0 -11
- data/lib/vizion/client/connection.rb +0 -39
- data/lib/vizion/client/references.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e43bbd643f07e604c25b793ec44970d0f095407dd4df8801fef000125656804
|
4
|
+
data.tar.gz: 28786f95f7ea80647206b2fa5ddc72e64e09b52f4997e0f130f4235a88afd027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef3b2d041629dc37137a3a13e61d885bfff4ffa009fe7db41abb8b14c75f727b28a0a47404377f4edac135c6eaf01425073bd2a6cee4b87a28009b6620ed52a
|
7
|
+
data.tar.gz: 9f3d9c2a66fc738a6a640ab52d17d979f30e01ddeae29df6b81000d650f66cafc06bc95c1db33f04ae6652f2a2a70e2d87c98fa615176865daae0992909e4fff
|
data/README.org
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#+TITLE: Vizion
|
2
|
+
#+AUTHOR: Jose Perez
|
3
|
+
#+EMAIL: jose.perez@vertilux.com
|
4
|
+
#+EXPORT_FILE_NAME: ./docs/index.html
|
5
|
+
#+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
|
6
|
+
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css">
|
7
|
+
#+OPTIONS: num:nil
|
8
|
+
|
9
|
+
Vizion is a ruby gem client library for talking to [[https://docs.vizionapi.com][VIZION API]] built using OpenStruct so you can easily access data in a Ruby-ish way.
|
10
|
+
|
11
|
+
[[https://badge.fury.io/rb/vizion.svg]]
|
12
|
+
|
13
|
+
** Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
#+begin_src ruby
|
17
|
+
gem 'vizion'
|
18
|
+
#+end_src
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
#+begin_src bash
|
22
|
+
bundle
|
23
|
+
#+end_src
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
#+begin_src ruby
|
27
|
+
gem install vizion
|
28
|
+
#+end_src
|
29
|
+
|
30
|
+
** Usage
|
31
|
+
You'll need to generate an api key: [[https://vizionapi.com/sign-up][https://vizionapi.com/sign-up]]
|
32
|
+
Initialize client and making request:
|
33
|
+
|
34
|
+
#+begin_src ruby
|
35
|
+
require 'vizion'
|
36
|
+
client = Vizion::Client.new(api_key: "X-API-Key", timeout: 10)
|
37
|
+
client.carriers
|
38
|
+
#+end_src
|
39
|
+
|
40
|
+
** Resources
|
41
|
+
|
42
|
+
*** Carriers
|
43
|
+
List of all supported carriers, to view the list [[https://www.notion.so/vizionapi/afa65e3d79fb4a33bc5ce5c331576668?v=a7543be9963441b8aa1ad33962774b85][click here]].
|
44
|
+
|
45
|
+
*Actions supported*:
|
46
|
+
#+begin_src ruby
|
47
|
+
client.carriers.list
|
48
|
+
#+end_src
|
49
|
+
|
50
|
+
*** References
|
51
|
+
|
52
|
+
*Actions supported*:
|
53
|
+
#+begin_src ruby
|
54
|
+
client.references.list
|
55
|
+
client.references.retrieve(id)
|
56
|
+
client.references.updates(id)
|
57
|
+
client.references.create({})
|
58
|
+
client.references.delete(id)
|
59
|
+
#+end_src
|
60
|
+
|
61
|
+
**** Pagination
|
62
|
+
Use the =page= query parameter to set the current page (default: 1)\\
|
63
|
+
Use the =per_page= query parameter to set a per page limit (default: 25)
|
64
|
+
|
65
|
+
#+begin_src ruby
|
66
|
+
client.references.list(per_page: 10, page:2)
|
67
|
+
#+end_src
|
68
|
+
|
69
|
+
**** Create Reference with Auto Carrier Identification.
|
70
|
+
Add container reference for update tracking without a carrier code. To do this, provide only a container_id with in the body request payload. Please note, it will always be faster and more accurate to provide a carrier code when you can.\\
|
71
|
+
VIZION API will periodically check for updates and send updates via HTTP POST to the provided =callback_url= parameter.
|
72
|
+
|
73
|
+
*Raw body*
|
74
|
+
#+begin_src json
|
75
|
+
{
|
76
|
+
"container_id": "CMAU4049810",
|
77
|
+
"callback_url": "https://yourdomain.com/webhook"
|
78
|
+
}
|
79
|
+
#+end_src
|
80
|
+
|
81
|
+
*Ruby way*
|
82
|
+
#+begin_src ruby
|
83
|
+
client.references.create(container_id: "CMAU4049810", callback_url: "https://yourdomain.com/webhook")
|
84
|
+
#+end_src
|
85
|
+
|
86
|
+
**** Create Reference with Carrier Code
|
87
|
+
Add container reference for update tracking using a carrier code.
|
88
|
+
|
89
|
+
*Raw body*
|
90
|
+
#+begin_src json
|
91
|
+
{
|
92
|
+
"container_id": "CAIU4482704",
|
93
|
+
"carrier_code": "HDMU",
|
94
|
+
"callback_url": "https://yourdomain.com/webhook"
|
95
|
+
}
|
96
|
+
#+end_src
|
97
|
+
|
98
|
+
*Ruby way*
|
99
|
+
#+begin_src ruby
|
100
|
+
client.references.create(container_id: "CMAU4049810", carrier_code: "HDMU", callback_url: "https://yourdomain.com/webhook")
|
101
|
+
#+end_src
|
102
|
+
|
103
|
+
If no callback_url parameter is provided, you will need to fetch status updates from the reference_updates action.
|
104
|
+
|
105
|
+
** Contributing
|
106
|
+
|
107
|
+
Everyone is encouraged to help improve this project. Bug reports and pull requests are welcome at [[https://github.com/vertilux/vizion/pulls]].
|
108
|
+
Feel free to open an [[https://github.com/lepepe/sagekit/issues][issue]] to get feedback on your idea before spending too much time on it.
|
109
|
+
|
110
|
+
** License
|
111
|
+
|
112
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/bin/console
CHANGED
data/docs/index.html
ADDED
@@ -0,0 +1,426 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
5
|
+
<head>
|
6
|
+
<!-- 2021-10-06 Wed 22:29 -->
|
7
|
+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
9
|
+
<title>Vizion</title>
|
10
|
+
<meta name="author" content="Jose Perez" />
|
11
|
+
<meta name="generator" content="Org Mode" />
|
12
|
+
<style>
|
13
|
+
#content { max-width: 60em; margin: auto; }
|
14
|
+
.title { text-align: center;
|
15
|
+
margin-bottom: .2em; }
|
16
|
+
.subtitle { text-align: center;
|
17
|
+
font-size: medium;
|
18
|
+
font-weight: bold;
|
19
|
+
margin-top:0; }
|
20
|
+
.todo { font-family: monospace; color: red; }
|
21
|
+
.done { font-family: monospace; color: green; }
|
22
|
+
.priority { font-family: monospace; color: orange; }
|
23
|
+
.tag { background-color: #eee; font-family: monospace;
|
24
|
+
padding: 2px; font-size: 80%; font-weight: normal; }
|
25
|
+
.timestamp { color: #bebebe; }
|
26
|
+
.timestamp-kwd { color: #5f9ea0; }
|
27
|
+
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
|
28
|
+
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
|
29
|
+
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
|
30
|
+
.underline { text-decoration: underline; }
|
31
|
+
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
|
32
|
+
p.verse { margin-left: 3%; }
|
33
|
+
pre {
|
34
|
+
border: 1px solid #e6e6e6;
|
35
|
+
border-radius: 3px;
|
36
|
+
background-color: #f2f2f2;
|
37
|
+
padding: 8pt;
|
38
|
+
font-family: monospace;
|
39
|
+
overflow: auto;
|
40
|
+
margin: 1.2em;
|
41
|
+
}
|
42
|
+
pre.src {
|
43
|
+
position: relative;
|
44
|
+
overflow: auto;
|
45
|
+
}
|
46
|
+
pre.src:before {
|
47
|
+
display: none;
|
48
|
+
position: absolute;
|
49
|
+
top: -8px;
|
50
|
+
right: 12px;
|
51
|
+
padding: 3px;
|
52
|
+
color: #555;
|
53
|
+
background-color: #f2f2f299;
|
54
|
+
}
|
55
|
+
pre.src:hover:before { display: inline; margin-top: 14px;}
|
56
|
+
/* Languages per Org manual */
|
57
|
+
pre.src-asymptote:before { content: 'Asymptote'; }
|
58
|
+
pre.src-awk:before { content: 'Awk'; }
|
59
|
+
pre.src-authinfo::before { content: 'Authinfo'; }
|
60
|
+
pre.src-C:before { content: 'C'; }
|
61
|
+
/* pre.src-C++ doesn't work in CSS */
|
62
|
+
pre.src-clojure:before { content: 'Clojure'; }
|
63
|
+
pre.src-css:before { content: 'CSS'; }
|
64
|
+
pre.src-D:before { content: 'D'; }
|
65
|
+
pre.src-ditaa:before { content: 'ditaa'; }
|
66
|
+
pre.src-dot:before { content: 'Graphviz'; }
|
67
|
+
pre.src-calc:before { content: 'Emacs Calc'; }
|
68
|
+
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
|
69
|
+
pre.src-fortran:before { content: 'Fortran'; }
|
70
|
+
pre.src-gnuplot:before { content: 'gnuplot'; }
|
71
|
+
pre.src-haskell:before { content: 'Haskell'; }
|
72
|
+
pre.src-hledger:before { content: 'hledger'; }
|
73
|
+
pre.src-java:before { content: 'Java'; }
|
74
|
+
pre.src-js:before { content: 'Javascript'; }
|
75
|
+
pre.src-latex:before { content: 'LaTeX'; }
|
76
|
+
pre.src-ledger:before { content: 'Ledger'; }
|
77
|
+
pre.src-lisp:before { content: 'Lisp'; }
|
78
|
+
pre.src-lilypond:before { content: 'Lilypond'; }
|
79
|
+
pre.src-lua:before { content: 'Lua'; }
|
80
|
+
pre.src-matlab:before { content: 'MATLAB'; }
|
81
|
+
pre.src-mscgen:before { content: 'Mscgen'; }
|
82
|
+
pre.src-ocaml:before { content: 'Objective Caml'; }
|
83
|
+
pre.src-octave:before { content: 'Octave'; }
|
84
|
+
pre.src-org:before { content: 'Org mode'; }
|
85
|
+
pre.src-oz:before { content: 'OZ'; }
|
86
|
+
pre.src-plantuml:before { content: 'Plantuml'; }
|
87
|
+
pre.src-processing:before { content: 'Processing.js'; }
|
88
|
+
pre.src-python:before { content: 'Python'; }
|
89
|
+
pre.src-R:before { content: 'R'; }
|
90
|
+
pre.src-ruby:before { content: 'Ruby'; }
|
91
|
+
pre.src-sass:before { content: 'Sass'; }
|
92
|
+
pre.src-scheme:before { content: 'Scheme'; }
|
93
|
+
pre.src-screen:before { content: 'Gnu Screen'; }
|
94
|
+
pre.src-sed:before { content: 'Sed'; }
|
95
|
+
pre.src-sh:before { content: 'shell'; }
|
96
|
+
pre.src-sql:before { content: 'SQL'; }
|
97
|
+
pre.src-sqlite:before { content: 'SQLite'; }
|
98
|
+
/* additional languages in org.el's org-babel-load-languages alist */
|
99
|
+
pre.src-forth:before { content: 'Forth'; }
|
100
|
+
pre.src-io:before { content: 'IO'; }
|
101
|
+
pre.src-J:before { content: 'J'; }
|
102
|
+
pre.src-makefile:before { content: 'Makefile'; }
|
103
|
+
pre.src-maxima:before { content: 'Maxima'; }
|
104
|
+
pre.src-perl:before { content: 'Perl'; }
|
105
|
+
pre.src-picolisp:before { content: 'Pico Lisp'; }
|
106
|
+
pre.src-scala:before { content: 'Scala'; }
|
107
|
+
pre.src-shell:before { content: 'Shell Script'; }
|
108
|
+
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
|
109
|
+
/* additional language identifiers per "defun org-babel-execute"
|
110
|
+
in ob-*.el */
|
111
|
+
pre.src-cpp:before { content: 'C++'; }
|
112
|
+
pre.src-abc:before { content: 'ABC'; }
|
113
|
+
pre.src-coq:before { content: 'Coq'; }
|
114
|
+
pre.src-groovy:before { content: 'Groovy'; }
|
115
|
+
/* additional language identifiers from org-babel-shell-names in
|
116
|
+
ob-shell.el: ob-shell is the only babel language using a lambda to put
|
117
|
+
the execution function name together. */
|
118
|
+
pre.src-bash:before { content: 'bash'; }
|
119
|
+
pre.src-csh:before { content: 'csh'; }
|
120
|
+
pre.src-ash:before { content: 'ash'; }
|
121
|
+
pre.src-dash:before { content: 'dash'; }
|
122
|
+
pre.src-ksh:before { content: 'ksh'; }
|
123
|
+
pre.src-mksh:before { content: 'mksh'; }
|
124
|
+
pre.src-posh:before { content: 'posh'; }
|
125
|
+
/* Additional Emacs modes also supported by the LaTeX listings package */
|
126
|
+
pre.src-ada:before { content: 'Ada'; }
|
127
|
+
pre.src-asm:before { content: 'Assembler'; }
|
128
|
+
pre.src-caml:before { content: 'Caml'; }
|
129
|
+
pre.src-delphi:before { content: 'Delphi'; }
|
130
|
+
pre.src-html:before { content: 'HTML'; }
|
131
|
+
pre.src-idl:before { content: 'IDL'; }
|
132
|
+
pre.src-mercury:before { content: 'Mercury'; }
|
133
|
+
pre.src-metapost:before { content: 'MetaPost'; }
|
134
|
+
pre.src-modula-2:before { content: 'Modula-2'; }
|
135
|
+
pre.src-pascal:before { content: 'Pascal'; }
|
136
|
+
pre.src-ps:before { content: 'PostScript'; }
|
137
|
+
pre.src-prolog:before { content: 'Prolog'; }
|
138
|
+
pre.src-simula:before { content: 'Simula'; }
|
139
|
+
pre.src-tcl:before { content: 'tcl'; }
|
140
|
+
pre.src-tex:before { content: 'TeX'; }
|
141
|
+
pre.src-plain-tex:before { content: 'Plain TeX'; }
|
142
|
+
pre.src-verilog:before { content: 'Verilog'; }
|
143
|
+
pre.src-vhdl:before { content: 'VHDL'; }
|
144
|
+
pre.src-xml:before { content: 'XML'; }
|
145
|
+
pre.src-nxml:before { content: 'XML'; }
|
146
|
+
/* add a generic configuration mode; LaTeX export needs an additional
|
147
|
+
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
|
148
|
+
pre.src-conf:before { content: 'Configuration File'; }
|
149
|
+
|
150
|
+
table { border-collapse:collapse; }
|
151
|
+
caption.t-above { caption-side: top; }
|
152
|
+
caption.t-bottom { caption-side: bottom; }
|
153
|
+
td, th { vertical-align:top; }
|
154
|
+
th.org-right { text-align: center; }
|
155
|
+
th.org-left { text-align: center; }
|
156
|
+
th.org-center { text-align: center; }
|
157
|
+
td.org-right { text-align: right; }
|
158
|
+
td.org-left { text-align: left; }
|
159
|
+
td.org-center { text-align: center; }
|
160
|
+
dt { font-weight: bold; }
|
161
|
+
.footpara { display: inline; }
|
162
|
+
.footdef { margin-bottom: 1em; }
|
163
|
+
.figure { padding: 1em; }
|
164
|
+
.figure p { text-align: center; }
|
165
|
+
.equation-container {
|
166
|
+
display: table;
|
167
|
+
text-align: center;
|
168
|
+
width: 100%;
|
169
|
+
}
|
170
|
+
.equation {
|
171
|
+
vertical-align: middle;
|
172
|
+
}
|
173
|
+
.equation-label {
|
174
|
+
display: table-cell;
|
175
|
+
text-align: right;
|
176
|
+
vertical-align: middle;
|
177
|
+
}
|
178
|
+
.inlinetask {
|
179
|
+
padding: 10px;
|
180
|
+
border: 2px solid gray;
|
181
|
+
margin: 10px;
|
182
|
+
background: #ffffcc;
|
183
|
+
}
|
184
|
+
#org-div-home-and-up
|
185
|
+
{ text-align: right; font-size: 70%; white-space: nowrap; }
|
186
|
+
textarea { overflow-x: auto; }
|
187
|
+
.linenr { font-size: smaller }
|
188
|
+
.code-highlighted { background-color: #ffff00; }
|
189
|
+
.org-info-js_info-navigation { border-style: none; }
|
190
|
+
#org-info-js_console-label
|
191
|
+
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
|
192
|
+
.org-info-js_search-highlight
|
193
|
+
{ background-color: #ffff00; color: #000000; font-weight: bold; }
|
194
|
+
.org-svg { width: 90%; }
|
195
|
+
</style>
|
196
|
+
<link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/htmlize.css"/>
|
197
|
+
<link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/readtheorg.css"/>
|
198
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
199
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
200
|
+
<script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/lib/js/jquery.stickytableheaders.min.js"></script>
|
201
|
+
<script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/js/readtheorg.js"></script>
|
202
|
+
<link rel="stylesheet" type="text/css" href="style.css">
|
203
|
+
</head>
|
204
|
+
<body>
|
205
|
+
<div id="content" class="content">
|
206
|
+
<h1 class="title">Vizion</h1>
|
207
|
+
<div id="table-of-contents" role="doc-toc">
|
208
|
+
<h2>Table of Contents</h2>
|
209
|
+
<div id="text-table-of-contents" role="doc-toc">
|
210
|
+
<ul>
|
211
|
+
<li><a href="#orgf8779f9">Installation</a></li>
|
212
|
+
<li><a href="#org1013cde">Usage</a></li>
|
213
|
+
<li><a href="#orgbc9c296">Resources</a>
|
214
|
+
<ul>
|
215
|
+
<li><a href="#org660d830">Carriers</a></li>
|
216
|
+
<li><a href="#org6a7f07c">References</a>
|
217
|
+
<ul>
|
218
|
+
<li><a href="#org2765593">Pagination</a></li>
|
219
|
+
<li><a href="#org5746618">Create Reference with Auto Carrier Identification.</a></li>
|
220
|
+
<li><a href="#org7ec6afa">Create Reference with Carrier Code</a></li>
|
221
|
+
</ul>
|
222
|
+
</li>
|
223
|
+
</ul>
|
224
|
+
</li>
|
225
|
+
<li><a href="#org4e26d3d">Contributing</a></li>
|
226
|
+
<li><a href="#orga2bcbef">License</a></li>
|
227
|
+
</ul>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
<p>
|
231
|
+
Vizion is a ruby gem client library for talking to <a href="https://docs.vizionapi.com">VIZION API</a> built using OpenStruct so you can easily access data in a Ruby-ish way.
|
232
|
+
</p>
|
233
|
+
|
234
|
+
|
235
|
+
<div id="org797ad4d" class="figure">
|
236
|
+
<p><img src="https://badge.fury.io/rb/vizion.svg" alt="vizion.svg" />
|
237
|
+
</p>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div id="outline-container-orgf8779f9" class="outline-2">
|
241
|
+
<h2 id="orgf8779f9">Installation</h2>
|
242
|
+
<div class="outline-text-2" id="text-orgf8779f9">
|
243
|
+
<p>
|
244
|
+
Add this line to your application’s Gemfile:
|
245
|
+
</p>
|
246
|
+
<div class="org-src-container">
|
247
|
+
<pre class="src src-ruby">gem <span style="color: #f1fa8c;">'vizion'</span>
|
248
|
+
</pre>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
<p>
|
252
|
+
And then execute:
|
253
|
+
</p>
|
254
|
+
<div class="org-src-container">
|
255
|
+
<pre class="src src-bash">bundle
|
256
|
+
</pre>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
<p>
|
260
|
+
Or install it yourself as:
|
261
|
+
</p>
|
262
|
+
<div class="org-src-container">
|
263
|
+
<pre class="src src-ruby">gem install vizion
|
264
|
+
</pre>
|
265
|
+
</div>
|
266
|
+
</div>
|
267
|
+
</div>
|
268
|
+
|
269
|
+
<div id="outline-container-org1013cde" class="outline-2">
|
270
|
+
<h2 id="org1013cde">Usage</h2>
|
271
|
+
<div class="outline-text-2" id="text-org1013cde">
|
272
|
+
<p>
|
273
|
+
You’ll need to generate an api key: <a href="https://vizionapi.com/sign-up">https://vizionapi.com/sign-up</a>
|
274
|
+
Initialize client and making request:
|
275
|
+
</p>
|
276
|
+
|
277
|
+
<div class="org-src-container">
|
278
|
+
<pre class="src src-ruby"><span style="color: #ffb86c;">require</span> <span style="color: #f1fa8c;">'vizion'</span>
|
279
|
+
client = <span style="color: #bd93f9;">Vizion</span>::<span style="color: #bd93f9;">Client</span>.new(<span style="color: #8be9fd;">api_key:</span> <span style="color: #f1fa8c;">"X-API-Key"</span>, <span style="color: #8be9fd;">timeout:</span> <span style="color: #bd93f9; font-weight: bold;">10</span>)
|
280
|
+
client.carriers
|
281
|
+
</pre>
|
282
|
+
</div>
|
283
|
+
</div>
|
284
|
+
</div>
|
285
|
+
|
286
|
+
<div id="outline-container-orgbc9c296" class="outline-2">
|
287
|
+
<h2 id="orgbc9c296">Resources</h2>
|
288
|
+
<div class="outline-text-2" id="text-orgbc9c296">
|
289
|
+
</div>
|
290
|
+
<div id="outline-container-org660d830" class="outline-3">
|
291
|
+
<h3 id="org660d830">Carriers</h3>
|
292
|
+
<div class="outline-text-3" id="text-org660d830">
|
293
|
+
<p>
|
294
|
+
List of all supported carriers, to view the list <a href="https://www.notion.so/vizionapi/afa65e3d79fb4a33bc5ce5c331576668?v=a7543be9963441b8aa1ad33962774b85">click here</a>.
|
295
|
+
</p>
|
296
|
+
|
297
|
+
<p>
|
298
|
+
<b>Actions supported</b>:
|
299
|
+
</p>
|
300
|
+
<div class="org-src-container">
|
301
|
+
<pre class="src src-ruby">client.carriers.list
|
302
|
+
</pre>
|
303
|
+
</div>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
<div id="outline-container-org6a7f07c" class="outline-3">
|
308
|
+
<h3 id="org6a7f07c">References</h3>
|
309
|
+
<div class="outline-text-3" id="text-org6a7f07c">
|
310
|
+
<p>
|
311
|
+
<b>Actions supported</b>:
|
312
|
+
</p>
|
313
|
+
<div class="org-src-container">
|
314
|
+
<pre class="src src-ruby">client.references.list
|
315
|
+
client.references.retrieve(id)
|
316
|
+
client.references.updates(id)
|
317
|
+
client.references.create({})
|
318
|
+
client.references.delete(id)
|
319
|
+
</pre>
|
320
|
+
</div>
|
321
|
+
</div>
|
322
|
+
|
323
|
+
<div id="outline-container-org2765593" class="outline-4">
|
324
|
+
<h4 id="org2765593">Pagination</h4>
|
325
|
+
<div class="outline-text-4" id="text-org2765593">
|
326
|
+
<p>
|
327
|
+
Use the <code>page</code> query parameter to set the current page (default: 1)<br />
|
328
|
+
Use the <code>per_page</code> query parameter to set a per page limit (default: 25)
|
329
|
+
</p>
|
330
|
+
|
331
|
+
<div class="org-src-container">
|
332
|
+
<pre class="src src-ruby">client.references.list(<span style="color: #8be9fd;">per_page:</span> <span style="color: #bd93f9; font-weight: bold;">10</span>, <span style="color: #8be9fd;">page:</span><span style="color: #bd93f9; font-weight: bold;">2</span>)
|
333
|
+
</pre>
|
334
|
+
</div>
|
335
|
+
</div>
|
336
|
+
</div>
|
337
|
+
|
338
|
+
<div id="outline-container-org5746618" class="outline-4">
|
339
|
+
<h4 id="org5746618">Create Reference with Auto Carrier Identification.</h4>
|
340
|
+
<div class="outline-text-4" id="text-org5746618">
|
341
|
+
<p>
|
342
|
+
Add container reference for update tracking without a carrier code. To do this, provide only a container<sub>id</sub> with in the body request payload. Please note, it will always be faster and more accurate to provide a carrier code when you can.<br />
|
343
|
+
VIZION API will periodically check for updates and send updates via HTTP POST to the provided <code>callback_url</code> parameter.
|
344
|
+
</p>
|
345
|
+
|
346
|
+
<p>
|
347
|
+
<b>Raw body</b>
|
348
|
+
</p>
|
349
|
+
<div class="org-src-container">
|
350
|
+
<pre class="src src-json">{
|
351
|
+
<span style="color: #ff79c6;">"container_id"</span>: <span style="color: #f1fa8c;">"CMAU4049810"</span>,
|
352
|
+
<span style="color: #ff79c6;">"callback_url"</span>: <span style="color: #f1fa8c;">"https://yourdomain.com/webhook"</span>
|
353
|
+
}
|
354
|
+
</pre>
|
355
|
+
</div>
|
356
|
+
|
357
|
+
<p>
|
358
|
+
<b>Ruby way</b>
|
359
|
+
</p>
|
360
|
+
<div class="org-src-container">
|
361
|
+
<pre class="src src-ruby">client.references.create(<span style="color: #8be9fd;">container_id:</span> <span style="color: #f1fa8c;">"CMAU4049810"</span>, <span style="color: #8be9fd;">callback_url:</span> <span style="color: #f1fa8c;">"https://yourdomain.com/webhook"</span>)
|
362
|
+
</pre>
|
363
|
+
</div>
|
364
|
+
</div>
|
365
|
+
</div>
|
366
|
+
|
367
|
+
<div id="outline-container-org7ec6afa" class="outline-4">
|
368
|
+
<h4 id="org7ec6afa">Create Reference with Carrier Code</h4>
|
369
|
+
<div class="outline-text-4" id="text-org7ec6afa">
|
370
|
+
<p>
|
371
|
+
Add container reference for update tracking using a carrier code.
|
372
|
+
</p>
|
373
|
+
|
374
|
+
<p>
|
375
|
+
<b>Raw body</b>
|
376
|
+
</p>
|
377
|
+
<div class="org-src-container">
|
378
|
+
<pre class="src src-json">{
|
379
|
+
<span style="color: #ff79c6;">"container_id"</span>: <span style="color: #f1fa8c;">"CAIU4482704"</span>,
|
380
|
+
<span style="color: #ff79c6;">"carrier_code"</span>: <span style="color: #f1fa8c;">"HDMU"</span>,
|
381
|
+
<span style="color: #ff79c6;">"callback_url"</span>: <span style="color: #f1fa8c;">"https://yourdomain.com/webhook"</span>
|
382
|
+
}
|
383
|
+
</pre>
|
384
|
+
</div>
|
385
|
+
|
386
|
+
<p>
|
387
|
+
<b>Ruby way</b>
|
388
|
+
</p>
|
389
|
+
<div class="org-src-container">
|
390
|
+
<pre class="src src-ruby">client.references.create(<span style="color: #8be9fd;">container_id:</span> <span style="color: #f1fa8c;">"CMAU4049810"</span>, <span style="color: #8be9fd;">carrier_code:</span> <span style="color: #f1fa8c;">"HDMU"</span>, <span style="color: #8be9fd;">callback_url:</span> <span style="color: #f1fa8c;">"https://yourdomain.com/webhook"</span>)
|
391
|
+
</pre>
|
392
|
+
</div>
|
393
|
+
|
394
|
+
<p>
|
395
|
+
If no callback<sub>url</sub> parameter is provided, you will need to fetch status updates from the reference<sub>updates</sub> action.
|
396
|
+
</p>
|
397
|
+
</div>
|
398
|
+
</div>
|
399
|
+
</div>
|
400
|
+
</div>
|
401
|
+
|
402
|
+
<div id="outline-container-org4e26d3d" class="outline-2">
|
403
|
+
<h2 id="org4e26d3d">Contributing</h2>
|
404
|
+
<div class="outline-text-2" id="text-org4e26d3d">
|
405
|
+
<p>
|
406
|
+
Everyone is encouraged to help improve this project. Bug reports and pull requests are welcome at <a href="https://github.com/vertilux/vizion/pulls">https://github.com/vertilux/vizion/pulls</a>.
|
407
|
+
Feel free to open an <a href="https://github.com/lepepe/sagekit/issues">issue</a> to get feedback on your idea before spending too much time on it.
|
408
|
+
</p>
|
409
|
+
</div>
|
410
|
+
</div>
|
411
|
+
|
412
|
+
<div id="outline-container-orga2bcbef" class="outline-2">
|
413
|
+
<h2 id="orga2bcbef">License</h2>
|
414
|
+
<div class="outline-text-2" id="text-orga2bcbef">
|
415
|
+
<p>
|
416
|
+
The gem is available as open source under the terms of the [MIT License](<a href="https://opensource.org/licenses/MIT">https://opensource.org/licenses/MIT</a>).
|
417
|
+
</p>
|
418
|
+
</div>
|
419
|
+
</div>
|
420
|
+
</div>
|
421
|
+
<div id="postamble" class="status">
|
422
|
+
<p class="author">Author: Jose Perez</p>
|
423
|
+
<p class="date">Created: 2021-10-06 Wed 22:29</p>
|
424
|
+
</div>
|
425
|
+
</body>
|
426
|
+
</html>
|
data/docs/style.css
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
/* Read the Org custom CSS */
|
2
|
+
|
3
|
+
/* Body andHeaders */
|
4
|
+
h4,h5,h6 {
|
5
|
+
color:#6272a4;
|
6
|
+
font-weight:300;
|
7
|
+
}
|
8
|
+
|
9
|
+
body{
|
10
|
+
background:#282A36;
|
11
|
+
color:#404040;
|
12
|
+
font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
|
13
|
+
font-weight:normal;
|
14
|
+
margin:0;
|
15
|
+
min-height:100%;
|
16
|
+
overflow-x:hidden;
|
17
|
+
}
|
18
|
+
|
19
|
+
/* Code block */
|
20
|
+
.codeblock,pre.src,#content .literal-block{
|
21
|
+
border:1px solid #e1e4e5;
|
22
|
+
padding:12px;
|
23
|
+
overflow-x:auto;
|
24
|
+
background:#282A36;
|
25
|
+
margin:1px 0 24px 0;
|
26
|
+
color: #F8F8F2;
|
27
|
+
}
|
28
|
+
|
29
|
+
/* Links */
|
30
|
+
a{
|
31
|
+
color:#6272a4;
|
32
|
+
text-decoration:none;
|
33
|
+
cursor:pointer}
|
34
|
+
|
35
|
+
a:hover,a:active{
|
36
|
+
outline:0;
|
37
|
+
}
|
38
|
+
|
39
|
+
a:hover{
|
40
|
+
color:#bd93f9}
|
41
|
+
|
42
|
+
a:visited{
|
43
|
+
color:#9B59B6}
|
44
|
+
|
45
|
+
/* Table of Content */
|
46
|
+
#table-of-contents{
|
47
|
+
position:fixed;
|
48
|
+
top:0;
|
49
|
+
left:0;
|
50
|
+
width:300px;
|
51
|
+
overflow-x:hidden;
|
52
|
+
overflow-y:scroll;
|
53
|
+
height:100%;
|
54
|
+
background:#44475A;
|
55
|
+
z-index:200;
|
56
|
+
scrollbar-base-color: #1F1D1D;
|
57
|
+
scrollbar-arrow-color: #b3b3b3;
|
58
|
+
scrollbar-shadow-color: #1F1D1D;
|
59
|
+
scrollbar-track-color : #343131;
|
60
|
+
}
|
61
|
+
|
62
|
+
#table-of-contents h2{
|
63
|
+
z-index:200;
|
64
|
+
background-color:#282A36;
|
65
|
+
text-align:center;
|
66
|
+
padding:0.809em;
|
67
|
+
display:block;
|
68
|
+
color:#fcfcfc;
|
69
|
+
font-size: 100%;
|
70
|
+
margin-bottom:0.809em}
|
71
|
+
|
72
|
+
/* Footer */
|
73
|
+
#postamble .author {
|
74
|
+
font-size: 100%;
|
75
|
+
margin-bottom: 0px;
|
76
|
+
}
|
77
|
+
|
78
|
+
#postamble .date {
|
79
|
+
font-size: 90%;
|
80
|
+
margin-bottom: 0px;
|
81
|
+
color: #00f769;
|
82
|
+
}
|
83
|
+
|
84
|
+
.figure {
|
85
|
+
padding: 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
.figure p {
|
89
|
+
text-align: left;
|
90
|
+
padding: 0;
|
91
|
+
}
|
data/lib/vizion/client.rb
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "vizion/client/carriers"
|
4
|
-
require "vizion/client/references"
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
5
3
|
|
6
4
|
module Vizion
|
7
5
|
class Client
|
8
|
-
|
9
|
-
include Vizion::Client::Connection
|
10
|
-
include Vizion::Client::Carriers
|
11
|
-
include Vizion::Client::References
|
6
|
+
BASE_URL = "https://prod.vizionapi.com"
|
12
7
|
|
13
|
-
|
8
|
+
attr_reader :api_key, :adapter
|
14
9
|
|
15
|
-
|
16
|
-
|
10
|
+
def initialize(api_key:, adapter: Faraday.default_adapter)
|
11
|
+
@api_key = api_key || ENV["VIZION_API_KEY"]
|
12
|
+
@adapter = adapter
|
13
|
+
end
|
14
|
+
|
15
|
+
def carriers
|
16
|
+
CarriersResource.new(self)
|
17
|
+
end
|
17
18
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
19
|
+
def references
|
20
|
+
ReferencesResource.new(self)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def connection
|
24
|
+
@connection ||= Faraday.new do |con|
|
25
|
+
con.url_prefix = BASE_URL
|
26
|
+
con.request :json
|
27
|
+
con.response :json, content_type: "application/json"
|
28
|
+
con.adapter adapter
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Vizion
|
2
|
+
class Collection
|
3
|
+
attr_reader :data, :page, :page_count, :per_page, :item_count
|
4
|
+
|
5
|
+
#Set include_metadata=true to receive pagination info in the response
|
6
|
+
#Use the page query parameter to set the current page (default: 1)
|
7
|
+
#Use the limit query parameter to set a per page limit (default: 25)
|
8
|
+
|
9
|
+
# from_response(response, key: "references", type: Reference)
|
10
|
+
def self.from_response(response, type:)
|
11
|
+
body = response.body
|
12
|
+
new(
|
13
|
+
data: body["data"].map{ |attrs| type.new(attrs) },
|
14
|
+
page: body.dig("metadata", "page"),
|
15
|
+
page_count: body.dig("metadata", "page_count"),
|
16
|
+
per_page: body.dig("metadata", "per_page"),
|
17
|
+
item_count: body.dig("metadata", "item_count")
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(data:, page:, page_count:, per_page:, item_count:)
|
22
|
+
@data = data
|
23
|
+
@page = page
|
24
|
+
@page_count = page_count
|
25
|
+
@per_page = per_page
|
26
|
+
@item_count = item_count
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/vizion/error.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
module Vizion
|
4
|
+
class Object
|
5
|
+
def initialize(attributes)
|
6
|
+
@attributes = OpenStruct.new(attributes)
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(method, *args, &block)
|
10
|
+
attribute = @attributes.send(method, *args, &block)
|
11
|
+
attribute.is_a?(Hash) ? Object.new(attribute) : attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
def respond_to_missing?(method, inlcude_private = false)
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Vizion
|
2
|
+
class Resource
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_request(url, params: {}, headers: {})
|
10
|
+
handle_response client.connection.get(url, params, default_headers.merge(headers))
|
11
|
+
end
|
12
|
+
|
13
|
+
def post_request(url, body:, headers: {})
|
14
|
+
handle_response client.connection.post(url, body, default_headers.merge(headers))
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete_request(url, params: {}, headers: {})
|
18
|
+
handle_response client.connection.delete(url, params, default_headers.merge(headers))
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_headers
|
22
|
+
{ 'X-Api-Key': client.api_key }
|
23
|
+
end
|
24
|
+
|
25
|
+
def handle_response(response)
|
26
|
+
case response.status
|
27
|
+
when 400
|
28
|
+
raise Error, "#{response.body}"
|
29
|
+
when 401
|
30
|
+
raise Error, "#{response.body}"
|
31
|
+
when 403
|
32
|
+
raise Error, "#{response.body}"
|
33
|
+
when 404
|
34
|
+
raise Error, "#{response.body}"
|
35
|
+
when 429
|
36
|
+
raise Error, "#{response.body}"
|
37
|
+
when 500
|
38
|
+
raise Error, "#{response.body}"
|
39
|
+
when 503
|
40
|
+
raise Error, "#{response.body}"
|
41
|
+
end
|
42
|
+
|
43
|
+
response
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Vizion
|
2
|
+
class ReferencesResource < Resource
|
3
|
+
|
4
|
+
def list(per_page: nil, page: nil)
|
5
|
+
params = {limit: per_page, page: page}.compact
|
6
|
+
Collection.from_response get_request("references?include_metadata=true", params: params), type: Reference
|
7
|
+
end
|
8
|
+
|
9
|
+
def retreive(id, **params)
|
10
|
+
Reference.new get_request("references/#{id}", params: params).body
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(**attributes)
|
14
|
+
Reference.new post_request("references", body: attributes).body
|
15
|
+
end
|
16
|
+
|
17
|
+
def updates(id, **params)
|
18
|
+
get_request("references/#{id}/updates", params: params).body
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(id)
|
22
|
+
delete_request("references/#{id}")
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/vizion/version.rb
CHANGED
data/lib/vizion.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
-
|
2
|
-
require "vizion/client"
|
3
|
-
require "httparty"
|
1
|
+
require_relative "vizion/version"
|
4
2
|
|
5
3
|
module Vizion
|
6
|
-
|
7
|
-
|
4
|
+
autoload :Client, "vizion/client"
|
5
|
+
autoload :Collection, "vizion/collection"
|
6
|
+
autoload :Error, "vizion/error"
|
7
|
+
autoload :Object, "vizion/object"
|
8
|
+
autoload :Resource, "vizion/resource"
|
9
|
+
|
10
|
+
autoload :CarriersResource, "vizion/resources/carriers"
|
11
|
+
autoload :ReferencesResource, "vizion/resources/references"
|
12
|
+
|
13
|
+
autoload :Carrier, "vizion/objects/carrier.rb"
|
14
|
+
autoload :Reference, "vizion/objects/reference.rb"
|
8
15
|
end
|
data/vizion.gemspec
CHANGED
@@ -10,15 +10,14 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["jose.perez@vertilux.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Client library Vizion API.}
|
13
|
-
spec.description = %q{
|
14
|
-
spec.homepage = "https://github.
|
13
|
+
spec.description = %q{Client library Vizion API.}
|
14
|
+
spec.homepage = "https://vertilux.github.io/vizion"
|
15
15
|
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = ">= 2.4.0"
|
16
17
|
|
17
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
20
|
if spec.respond_to?(:metadata)
|
20
|
-
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
|
22
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
23
22
|
spec.metadata["source_code_uri"] = "https://github.com/vertilux/vizion"
|
24
23
|
else
|
@@ -35,8 +34,6 @@ Gem::Specification.new do |spec|
|
|
35
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
35
|
spec.require_paths = ["lib"]
|
37
36
|
|
38
|
-
spec.
|
39
|
-
spec.
|
40
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
-
spec.add_dependency "httparty", "~> 0.18.1"
|
37
|
+
spec.add_dependency "faraday", "~> 0.9"
|
38
|
+
spec.add_dependency "faraday_middleware", "~> 0.14.0"
|
42
39
|
end
|
metadata
CHANGED
@@ -1,72 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vizion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Perez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.a
|
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.5.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.5.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
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
24
|
- - "~>"
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
26
|
+
version: '0.9'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
28
|
+
name: faraday_middleware
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - "~>"
|
60
32
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
33
|
+
version: 0.14.0
|
62
34
|
type: :runtime
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
38
|
- - "~>"
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
69
|
-
description:
|
40
|
+
version: 0.14.0
|
41
|
+
description: Client library Vizion API.
|
70
42
|
email:
|
71
43
|
- jose.perez@vertilux.com
|
72
44
|
executables: []
|
@@ -80,22 +52,29 @@ files:
|
|
80
52
|
- CODE_OF_CONDUCT.md
|
81
53
|
- Gemfile
|
82
54
|
- LICENSE.txt
|
83
|
-
- README.
|
55
|
+
- README.org
|
84
56
|
- Rakefile
|
85
57
|
- bin/console
|
86
58
|
- bin/setup
|
59
|
+
- docs/index.html
|
60
|
+
- docs/style.css
|
87
61
|
- lib/vizion.rb
|
88
62
|
- lib/vizion/client.rb
|
89
|
-
- lib/vizion/
|
90
|
-
- lib/vizion/
|
91
|
-
- lib/vizion/
|
63
|
+
- lib/vizion/collection.rb
|
64
|
+
- lib/vizion/error.rb
|
65
|
+
- lib/vizion/object.rb
|
66
|
+
- lib/vizion/objects/carrier.rb
|
67
|
+
- lib/vizion/objects/reference.rb
|
68
|
+
- lib/vizion/resource.rb
|
69
|
+
- lib/vizion/resources/carriers.rb
|
70
|
+
- lib/vizion/resources/references.rb
|
92
71
|
- lib/vizion/version.rb
|
93
72
|
- vizion.gemspec
|
94
|
-
homepage: https://github.
|
73
|
+
homepage: https://vertilux.github.io/vizion
|
95
74
|
licenses:
|
96
75
|
- MIT
|
97
76
|
metadata:
|
98
|
-
homepage_uri: https://github.
|
77
|
+
homepage_uri: https://vertilux.github.io/vizion
|
99
78
|
source_code_uri: https://github.com/vertilux/vizion
|
100
79
|
post_install_message:
|
101
80
|
rdoc_options: []
|
@@ -105,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
84
|
requirements:
|
106
85
|
- - ">="
|
107
86
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
87
|
+
version: 2.4.0
|
109
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
89
|
requirements:
|
111
90
|
- - ">="
|
data/README.md
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
# Vizion
|
2
|
-
|
3
|
-
Vizion is a ruby gem client library for talking to [VIZION API](https://docs.vizionapi.com/)
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'vizion'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install vizion
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
You'll need to generate an api key: [https://vizionapi.com/sign-up](https://vizionapi.com/sign-up).
|
24
|
-
Initialize client and making request:
|
25
|
-
|
26
|
-
``` ruby
|
27
|
-
require 'vizion'
|
28
|
-
client = Vizion::Client.new(api_key: "X-API-Key")
|
29
|
-
client.carriers
|
30
|
-
```
|
31
|
-
|
32
|
-
### Timeouts
|
33
|
-
|
34
|
-
You may also set timeout on the client.
|
35
|
-
|
36
|
-
```ruby
|
37
|
-
require 'vizion'
|
38
|
-
client = Vtxkit::Client.new(api_key: "X-API-Key", timeout: 10, # response timeout in seconds)
|
39
|
-
```
|
40
|
-
|
41
|
-
## List of methods
|
42
|
-
|
43
|
-
### Carriers
|
44
|
-
List of all supported carriers, to view the list [click here](https://www.notion.so/afa65e3d79fb4a33bc5ce5c331576668?v=a7543be9963441b8aa1ad33962774b85).
|
45
|
-
|
46
|
-
Actions supported:
|
47
|
-
|
48
|
-
```ruby
|
49
|
-
client.carriers
|
50
|
-
```
|
51
|
-
|
52
|
-
### References
|
53
|
-
|
54
|
-
Actions supported:
|
55
|
-
|
56
|
-
```ruby
|
57
|
-
client.all_references
|
58
|
-
client.create_reference
|
59
|
-
client.reference(id)
|
60
|
-
client.reference_updates(id)
|
61
|
-
client.delete_reference(id)
|
62
|
-
```
|
63
|
-
|
64
|
-
For the create_reference action include request body:
|
65
|
-
|
66
|
-
```json
|
67
|
-
{
|
68
|
-
"container_id": "CMAU4049810",
|
69
|
-
"scac": "CMAU",
|
70
|
-
"callback_url": "https://yourdomain.com/webhook"
|
71
|
-
}
|
72
|
-
```
|
73
|
-
If no callback_url parameter is provided, you will need to fetch status updates from the reference_updates action.
|
74
|
-
|
75
|
-
## Contributing
|
76
|
-
|
77
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/vertilux/vizion. 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.
|
78
|
-
|
79
|
-
## License
|
80
|
-
|
81
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
82
|
-
|
83
|
-
## Code of Conduct
|
84
|
-
|
85
|
-
Everyone interacting in the Vizion project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/vertilux/vizion/blob/master/CODE_OF_CONDUCT.md).
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Vizion
|
2
|
-
class Client
|
3
|
-
module Connection
|
4
|
-
|
5
|
-
def get(path, options = {})
|
6
|
-
request :get, path, options
|
7
|
-
end
|
8
|
-
|
9
|
-
def post(path, options = {})
|
10
|
-
request :post, path, options
|
11
|
-
end
|
12
|
-
|
13
|
-
def delete(path, options = {})
|
14
|
-
request :delete, path, options
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
def request(http_method, path, options)
|
19
|
-
begin
|
20
|
-
response = self.class.send(http_method, path, { body: options })
|
21
|
-
status = response.code.to_i
|
22
|
-
case status
|
23
|
-
when 200 then data = response.parsed_response
|
24
|
-
when 400 then data = "Bad Request"
|
25
|
-
when 401 then data = "Unauthorized"
|
26
|
-
when 403 then data = "Forbidden"
|
27
|
-
when 500 then data = "Internal Server Error"
|
28
|
-
when 502 then data = "Bad Gateway"
|
29
|
-
when 503 then data = "Service Unavailable"
|
30
|
-
end
|
31
|
-
rescue Net::ReadTimeout => exception
|
32
|
-
data = "Error Read Timeout"
|
33
|
-
rescue Errno::ECONNREFUSED
|
34
|
-
data = "Connection refused"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Vizion
|
2
|
-
class Client
|
3
|
-
module References
|
4
|
-
|
5
|
-
def all_references(options = {})
|
6
|
-
get("/references", options)
|
7
|
-
end
|
8
|
-
|
9
|
-
def create_reference(options)
|
10
|
-
post("/references", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def reference(id)
|
14
|
-
get("/references/#{id}")
|
15
|
-
end
|
16
|
-
|
17
|
-
def reference_updates(id)
|
18
|
-
get("/references/#{id}/updates")
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete_reference(id)
|
22
|
-
delete("/references/#{id}")
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|