vizion 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f000846e869a4edb42e9e9e6dcf90b901c2afaf923bdd4f82f7fe50a8af34f68
4
- data.tar.gz: 285be0933a913e2e3561861b85e00e1a970fb8ff34589aa46639e87451510ec0
3
+ metadata.gz: 6957ac4f48e1c12e5839ba41799be135d16ea601fe2b345d1ca4fdc2696a7f00
4
+ data.tar.gz: c19d84f9a1407923cf1d9048919fa5c6f87f915d3f1e34b7ebc96981c423ecaf
5
5
  SHA512:
6
- metadata.gz: e95c4af0805d25babcbb6965ba4efd768d43d5908d387baf88d54b559c930511c8a7b047ddd1e432e264ec245781d6113ac0a9fb29eaf265884c8c262aa1c7fd
7
- data.tar.gz: b5f4580f2eb8f67d4d50caabe115a8e15ec786f23ce0e95ce4363cd663f704a52a8e03a4e10ceca56b310e13601e010e35ce20932e789faa148592507828e7a8
6
+ metadata.gz: 509ceddc5e5b2bbdef257bf35093ceafa93b8d7c1c817a1670cd9990c7afc473764af915b47a00bedab1fdd15d2855247ef43cb92725c1664c30c96f1495bd3d
7
+ data.tar.gz: b21e81626f43e1d0bf8417a9ffe6ecdcc9d72ae3dccff88e13bcdaf6bb3b745070adbcf038b27c0d454ab4599f991e3f589a7e40c6c77c1475ab68cbd824c193
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [lepepe] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/README.md CHANGED
@@ -24,20 +24,35 @@ You'll need to generate an api key: [https://vizionapi.com/sign-up](https://vizi
24
24
  Initialize client and making request:
25
25
 
26
26
  ``` ruby
27
- client = Vizion::Client.new("X-API-Key")
27
+ require 'vizion'
28
+ client = Vizion::Client.new(api_key: "X-API-Key")
28
29
  client.carriers
29
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
+
30
41
  ## List of methods
31
42
 
32
43
  ### Carriers
33
44
  List of all supported carriers, to view the list [click here](https://www.notion.so/afa65e3d79fb4a33bc5ce5c331576668?v=a7543be9963441b8aa1ad33962774b85).
34
45
 
46
+ Actions supported:
47
+
35
48
  ```ruby
36
49
  client.carriers
37
50
  ```
38
51
 
39
52
  ### References
40
53
 
54
+ Actions supported:
55
+
41
56
  ```ruby
42
57
  client.all_references
43
58
  client.create_reference
@@ -45,9 +60,21 @@ client.reference(id)
45
60
  client.reference_updates(id)
46
61
  client.delete_reference(id)
47
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
+
48
75
  ## Contributing
49
76
 
50
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
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.
51
78
 
52
79
  ## License
53
80
 
@@ -55,4 +82,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
55
82
 
56
83
  ## Code of Conduct
57
84
 
58
- 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/[USERNAME]/vizion/blob/master/CODE_OF_CONDUCT.md).
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).
data/lib/vizion/client.rb CHANGED
@@ -10,12 +10,19 @@ module Vizion
10
10
  include Vizion::Client::Carriers
11
11
  include Vizion::Client::References
12
12
 
13
+ DEFAULT_TIMEOUT = 120
14
+
13
15
  base_uri "https://prod.vizionapi.com"
14
16
  format :json
15
17
 
16
- def initialize(api_key = nil)
17
- api_key ||= ENV["VIZION_API_KEY"]
18
- self.class.default_options.merge!(headers: { 'X-API-Key' => "#{api_key}" })
18
+ def initialize(options = {})
19
+ @api_key = options[:api_key] || ENV["VIZION_API_KEY"]
20
+ @timeout = options[:timeout] || DEFAULT_TIMEOUT
21
+
22
+ self.class.default_options.merge!(
23
+ headers: { 'X-Api-Key' => @api_key },
24
+ timeout: @timeout
25
+ )
19
26
  end
20
27
  end
21
28
  end
@@ -15,12 +15,25 @@ module Vizion
15
15
  end
16
16
 
17
17
  private
18
-
19
- def request(http_method, path, options)
20
- response = self.class.send(http_method, path, { body: options })
21
- data = response.parsed_response
22
- end
23
-
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
24
37
  end
25
38
  end
26
39
  end
@@ -1,3 +1,3 @@
1
1
  module Vizion
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vizion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-05-18 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/FUNDING.yml"
76
77
  - ".gitignore"
77
78
  - ".rspec"
78
79
  - ".travis.yml"
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
113
114
  requirements: []
114
- rubygems_version: 3.2.15
115
+ rubygems_version: 3.2.21
115
116
  signing_key:
116
117
  specification_version: 4
117
118
  summary: Client library Vizion API.