rtx-api 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: 2bca2da1db0ca31062e9b1a02f21d05e4888c682
4
- data.tar.gz: 9d0d852f80c4483cd244ad752dad210998a18db9
3
+ metadata.gz: 1d07f27e94f812c2b5ccbe8b88db45ac143f235f
4
+ data.tar.gz: 1870fed081935a8eb94375cb14d5ad6019aa726b
5
5
  SHA512:
6
- metadata.gz: c7d363c52581f95f38b5b4a6679192282046cb95192958139e521a390732a1ab75e1b8e9e495bc5d9a5a51535543dbc6610d7f5e8c58e2e63cfbc7a390bb7bd2
7
- data.tar.gz: c4e02c8e371e1d9f623779d61c91fedbe7086d6d08274e82010080a2a5728d5ce369d300e5b85184c011faafc8b63179b3196d1887fb6af06c117f4978386aac
6
+ metadata.gz: 62bf561923b34c05841d5146132e644e721b357e63076bb73e95478b1ac9a447ac67c45686aa8968479f689245f31350cc150858d945bc2e97509ea6f8951a1b
7
+ data.tar.gz: 8e8dee210c598a5c2074358c9f55d2ae0ecc3609d8276d72695f0e2a074ca89b6e2ad4fbed2e5618a134a6f60cb8f5376947091e8474626766c614d13487f177
data/README.md CHANGED
@@ -24,7 +24,7 @@ The client is lazily loaded, which means it will not authenticate until you make
24
24
 
25
25
  ### Initialization of the Client
26
26
 
27
- Based on if you have your environment variables for RTX_API_EMAIL and RTX_API_PASSWORD configured
27
+ Based on if you have your environment variables for `RTX_USER_EMAIL` and `RTX_USER_PASSWORD` configured
28
28
 
29
29
  ```ruby
30
30
  client = RTX::API::Client.new
@@ -17,14 +17,14 @@ module RTX
17
17
 
18
18
  def authenticate
19
19
  request = self.class.post("#{rtx_api_url}/auth", headers: default_headers, basic_auth: {username: email, password: password})
20
- response = Oj.load(request.body)
20
+ response = Oj.load(request.body, symbol_keys: true)
21
21
  if request.code != 201
22
22
  raise API::Errors::AuthenticationError.new("Authentication Login Error: #{response}")
23
23
  end
24
- @token = response["token"]
25
- @expires = response["expires_at"]
26
- @account_id = response["account_id"]
27
- @profile_id = response["profile_id"]
24
+ @token = response[:token]
25
+ @expires = response[:expires_at]
26
+ @account_id = response[:account_id]
27
+ @profile_id = response[:profile_id]
28
28
  end
29
29
 
30
30
  def logout
@@ -85,12 +85,12 @@ module RTX
85
85
  return true
86
86
  end
87
87
 
88
- Oj.load(request.body)
88
+ Oj.load(request.body, symbol_keys: true)
89
89
  end
90
90
 
91
91
  def resource_exists?(resource_name)
92
92
  allowed_resources = API::Resources.allowed_resources
93
- if !allowed_resources.include? resource_name
93
+ if !allowed_resources.include? resource_name.to_s
94
94
  raise API::Errors::InvalidResourceError.new("The resource provided (#{resource_name}) is not allowed")
95
95
  end
96
96
 
@@ -129,4 +129,4 @@ module RTX
129
129
  end
130
130
  end
131
131
  end
132
- end
132
+ end
@@ -5,7 +5,7 @@ module RTX
5
5
 
6
6
  def initialize(client, resource_name, attrs = {})
7
7
  @client = client
8
- @resource_name = resource_name
8
+ @resource_name = resource_name.to_sym
9
9
  @options = symbolize_hash(attrs)
10
10
  @response = {}
11
11
  end
@@ -46,14 +46,14 @@ module RTX
46
46
  def data
47
47
  client.authenticate if !client.authenticated?
48
48
  get if !has_response?
49
- response["_embedded"][resource_name]
49
+ response[:_embedded][resource_name]
50
50
  end
51
51
 
52
52
  # Returns the metadata about the current response
53
53
  def meta
54
54
  client.authenticate if !client.authenticated?
55
55
  get if !has_response?
56
- response.reject {|key,_| key == "_embedded"}
56
+ response.reject {|key,_| key == :_embedded}
57
57
  end
58
58
 
59
59
  # For moving forward one page with the collection
@@ -74,7 +74,7 @@ module RTX
74
74
 
75
75
  # For moving to the last page of the collection
76
76
  def last
77
- page(meta["_total_pages"])
77
+ page(meta[:_total_pages])
78
78
  self
79
79
  end
80
80
 
@@ -86,7 +86,7 @@ module RTX
86
86
 
87
87
  # Responds true if the collection has another page ahead of it
88
88
  def has_next?
89
- current_page < meta["_total_pages"]
89
+ current_page < meta[:_total_pages]
90
90
  end
91
91
 
92
92
  # Responds true if the collection has a previous one
@@ -98,7 +98,7 @@ module RTX
98
98
  def all_pages(initial_page = 1, &block)
99
99
  page(initial_page)
100
100
 
101
- pages = (current_page..meta["_total_pages"]).to_a
101
+ pages = (current_page..meta[:_total_pages]).to_a
102
102
  pages.each do |page_num|
103
103
  block.call(page(page_num).data)
104
104
  end
@@ -120,7 +120,7 @@ module RTX
120
120
  end
121
121
 
122
122
  def current_page
123
- @options[:page] = options[:page].nil? ? meta["_page"] : options[:page]
123
+ @options[:page] = options[:page].nil? ? meta[:_page] : options[:page]
124
124
  options[:page]
125
125
  end
126
126
 
@@ -151,4 +151,4 @@ module RTX
151
151
  end
152
152
  end
153
153
  end
154
- end
154
+ end
@@ -1,5 +1,5 @@
1
1
  module RTX
2
2
  module API
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtx-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ReviewTrackers Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -87,3 +87,4 @@ signing_key:
87
87
  specification_version: 4
88
88
  summary: Ruby Client for the Review Trackers RTX API.
89
89
  test_files: []
90
+ has_rdoc: