nds_api 0.1.4 → 0.1.5

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: e6687ce34b5ec1ec79eb2d45a87055b048390198d2314d17a19b0db0e2ec67b1
4
- data.tar.gz: 698a516992e80eb4594eb9385ca187ef9f9e68eeec41560a1fcee55bb8d79d5e
3
+ metadata.gz: bede4a8506fc380d9bd6d63df20bb578c490f456bdd457eec5f4d345c400f950
4
+ data.tar.gz: 900b97a2513d62b0d005b9b35314b5ef6ead66175236426207ad1722576243de
5
5
  SHA512:
6
- metadata.gz: 7ea4a7c2b5859adda111e010297ac28714b18099967b2c3acea49301e59e19215187a17696806b34201bc7d4e359f89dab70623440d72ba68dfc4f53b91da6b4
7
- data.tar.gz: '01561892fc9bef85d6484ec231f323a75be3bc6929b306470f74e53df554db002b5b401d9fb805ebb6653d1caedd9984a5ed490c6d1e8650b630f15299e1a09d'
6
+ metadata.gz: cfd85e34d774dcb55810fdef033cc63cdf4b8f966e5aa76ba0a8cc6ef7ab9448b1a3c02ed8d0ae595d762f750765102838c27c406e7e1711e76675737074aa13
7
+ data.tar.gz: 0fe689193d5692ee11a4e40ac75510ff51d6d9d85c7d06f685036de85ad8c1a88ab0e349f87e3a1a1950285b4dd136d92de01d6a931535cb68c5bee5e011e02c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nds_api (0.1.4)
4
+ nds_api (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -22,11 +22,27 @@ Or install it yourself as:
22
22
 
23
23
  ```ruby
24
24
  nds = NdsApi::Client.new(
25
- user: 'username',
26
- password: '############'
25
+ user: 'username', #required
26
+ password: '############', #required
27
+ agency_key: 123 # optionals
27
28
  )
28
29
  ```
29
30
 
31
+ ##### AGENCY
32
+
33
+ Get Agency Option By Id
34
+
35
+ ```ruby
36
+ nds.get_agency_option(option_id)
37
+ ```
38
+
39
+
40
+ Required: agency_key param, see usage section.
41
+
42
+ Will raise 'NDS API GEM: Agency Key required' if Agency Key not specified
43
+
44
+ Contact NDS to get your agency key.
45
+
30
46
  ##### CLIENT
31
47
 
32
48
 
@@ -12,7 +12,7 @@ module NdsApi
12
12
  def get(url)
13
13
  JSON.parse(open(url, http_basic_authentication: [api_user, api_password]).read)
14
14
  rescue => e
15
- puts "failed #{e}"
15
+ puts "NDS API GEM: #{e} (#{url})"
16
16
  return e
17
17
  end
18
18
 
@@ -38,7 +38,7 @@ module NdsApi
38
38
  response = Net::HTTP.new(url.host, url.port).request(req)
39
39
  JSON.parse(response.body)
40
40
  rescue => e
41
- puts "failed #{e}"
41
+ puts "NDS API GEM: #{e} (#{post_or_put}:#{url})"
42
42
  return e
43
43
  end
44
44
 
@@ -1,7 +1,15 @@
1
1
  module NdsApi
2
2
  class Url
3
3
  def initialize(options = { dev: false })
4
- @prod = !options[:dev]
4
+ @options = options
5
+ @prod = !@options[:dev]
6
+ end
7
+
8
+ ##### Agency #####
9
+
10
+ def get_agency_option(type_id=nil)
11
+ raise 'NDS API GEM: Agency Key required' unless @options[:agency_key]
12
+ "#{base_url}/agencies/config/options?agencyKey=#{@options[:agency_key]}#{type_id ? "&typeId=#{type_id}" : ''}"
5
13
  end
6
14
 
7
15
  ##### CLIENTS #####
@@ -3,6 +3,7 @@ module NdsApi
3
3
  class << self
4
4
 
5
5
  def hash_keys_str_to_sym(hash)
6
+ return hash unless hash.is_a? Hash
6
7
  hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
7
8
  end
8
9
 
@@ -1,3 +1,3 @@
1
1
  module NdsApi
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nds_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Hunault
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler