rtx-api 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3e8e770ba4720010d7e1b230e02327da4a26b0da
4
- data.tar.gz: 49141abf05dc7227b67d7469f4cc8ad32970a603
2
+ SHA256:
3
+ metadata.gz: f814c532170891e526790baba2601785abab70e68d528d205636193ef0307eec
4
+ data.tar.gz: 1d95ed32188e0b5adb877df739508ef8e42308656b62df1ee4fec660d5fb17d5
5
5
  SHA512:
6
- metadata.gz: f0a2083bb4061e976d501a742ed33fc0b392e3ce2cf366e081de77599132b61f412720ed9cd1de95cbe46b9ea355d7384522c54b7d3603d9459c00a9ca469c87
7
- data.tar.gz: 3e15cce436dae73c010af01792146f24ab475e2eb35bf4b939586d9ea7a8d9f1d93b3a78dc9d8bd4369f284b6736186dabf27302718a6523008cfce40c170204
6
+ metadata.gz: 57841fbfd405bbcda5f12c04b120720b1a4e9808c403cb160e1c5dc636475e263823bb769af66f7a3ae74acbbd0a767d8612d6fcaed76d00ac2f1aad17593bd7
7
+ data.tar.gz: a9e930cce3c9654c32e6944ff0e5872a8a97494f6e4dcc12210bc79f67379791a5e347587358dedfa56b011d7f06a2dd63382386f71b2c2029609335e544386d
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
+ addons:
3
+ code_climate:
4
+ repo_token: 0a659ed837c1f84266607a52710053cb96ff09edf9589cc16c7820cb21289987
2
5
  gemfile:
3
6
  - Gemfile
4
7
  rvm:
@@ -9,4 +12,10 @@ script:
9
12
  - bundle exec rake test
10
13
  env:
11
14
  global:
12
- secure: ZKA3gxZ13JbmstnDo0FOVUxnWvU2uY4tI/zjob4Lyu9sYrnI7ge7LSf8RNbpwmLdzHT45OgD5LrV4dQp6Z2lmDJygQBQXkZ+tnyPrxDvEWKhjH70ve6EJ5qzQxrAiIX9iP4iWJ7t3HPI3yEwCyaVjlFKFyGq0eTaalnvIadQRImfTh8yp7v4Kpg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7zzcuEV32xr0/ogGInR/ccUZXXnG6RCSBgXE+1Pp3xQS+iR39ND3Su7IViVsmMBhcMxdGPGTlVufBFhZtHS+qhze5XbS39jRp05cvYzjao1I6Mvt+C+KAxb4v6fzUSNAdNgVWLnUlmhkcE8=
17
+ branches:
18
+ only:
19
+ - master
20
+ after_script:
21
+ - bundle exec codeclimate-test-reporter
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rtx-api-client-ruby [![Build Status](https://travis-ci.org/reviewtrackers/rtx-api-client-ruby.svg?branch=master)](https://travis-ci.org/reviewtrackers/rtx-api-client-ruby)
1
+ # rtx-api-client-ruby [![Build Status](https://travis-ci.com/reviewtrackers/rtx-api-client-ruby.svg?token=LBGpi53KtKBbpp2CUDq4&branch=master)](https://travis-ci.com/reviewtrackers/rtx-api-client-ruby)
2
2
 
3
3
  Ruby Client for the RTX API.
4
4
 
@@ -18,6 +18,18 @@ By adding `RTX_USER_EMAIL` and `RTX_USER_PASSWORD` to your environment variables
18
18
 
19
19
  If you using a different url for for the RTX API, you can set the `RTX_API_URL` environment variable to use the appropriate one.
20
20
 
21
+ ## Testing locally
22
+
23
+ In order to test changes to your gem without having to release, you can update the Gemfile to point to the local version of the Gem
24
+
25
+ gem 'rtx-api', require: 'rtx/api', path: '../rtx-api-client-ruby'
26
+
27
+ ## Releasing new version
28
+
29
+ Bump the version of the gem within `./lib/rtx/api/version.rb` based on the changes you've made. Once your changes have been merged into master, you can release updated version of your gem. In order to release, you will need to be an owner of the RubyGems project and need to have your API credentials setup in your bash profile. Once complete, run the following command release command.
30
+
31
+ bundle exec rake release
32
+
21
33
  ## Usage
22
34
 
23
35
  The client is lazily loaded, which means it will not authenticate until you make your initial request. Once the request is performed, we'll store the information for future requests. You will want to use the same instance of the client to perform all of your requests.
@@ -8,6 +8,7 @@ require "rtx/api/client"
8
8
  # resources
9
9
  require "rtx/api/resources"
10
10
  require "rtx/api/collection"
11
+ require "rtx/api/collection_v2"
11
12
 
12
13
  # errors
13
14
  require "rtx/api/errors/client_error"
@@ -59,6 +59,10 @@ module RTX
59
59
  if args.size > 0
60
60
  attrs = args.last.is_a?(Hash) ? args.pop : {}
61
61
  end
62
+
63
+ # Use V2 Collection if prefixed with V2
64
+ return RTX::API::CollectionV2.new(self, method, attrs) if method.to_s.start_with?('v2_')
65
+
62
66
  RTX::API::Collection.new(self, method, attrs)
63
67
  end
64
68
  end
@@ -0,0 +1,130 @@
1
+ module RTX
2
+ module API
3
+ class CollectionV2
4
+ attr_accessor :client, :resource_name, :response, :options
5
+
6
+ def initialize(client, resource_name, attrs = {})
7
+ @client = client
8
+ @resource_name = resource_name.to_sym
9
+ @options = symbolize_hash(attrs)
10
+ @response = {}
11
+ end
12
+
13
+ # Chainable method that allows you to set the per page number of the collection for your request
14
+ def per_page(num)
15
+ clear if !num.nil?
16
+ @options[:per_page] = num
17
+ self
18
+ end
19
+
20
+ # Returns all data associated with the existing response
21
+ def data
22
+ client.authenticate if !client.authenticated?
23
+ collection if !has_response?
24
+ response[:data]
25
+ end
26
+
27
+ # Returns the paging information about the current response
28
+ def paging
29
+ client.authenticate if !client.authenticated?
30
+ collection if !has_response?
31
+ response[:paging]
32
+ end
33
+
34
+ # For moving forward one page with the collection
35
+ def next
36
+ if has_next?
37
+ next_page(after_token)
38
+ end
39
+ self
40
+ end
41
+
42
+ # For moving backward one page with the collection
43
+ def prev
44
+ if has_previous?
45
+ previous_page(before_token)
46
+ end
47
+ self
48
+ end
49
+
50
+ # Responds true if the collection has another page ahead of it
51
+ def has_next?
52
+ !after_token.nil?
53
+ end
54
+
55
+ # Responds true if the collection has a previous one
56
+ def has_previous?
57
+ !before_token.nil?
58
+ end
59
+
60
+ # Allows you to loop through all of the pages and retrieve the records
61
+ def all_pages(&block)
62
+ loop do
63
+ # Return first page
64
+ block.call(data)
65
+
66
+ # No need to continue if all data is retrieved
67
+ break unless has_next?
68
+
69
+ # Navigate to the next page
70
+ self.next
71
+ end
72
+ end
73
+
74
+ # Allows you to loop through all of the resources within the pages specified and retrieve the records
75
+ def all_resources(&block)
76
+ all_pages do |page|
77
+ page.each do |resource|
78
+ block.call(resource)
79
+ end
80
+ end
81
+ end
82
+
83
+ protected
84
+
85
+ # Chainable method that allows you to get the next page for a given after token
86
+ def next_page(after_token)
87
+ clear
88
+ @options[:after] = after_token
89
+ self
90
+ end
91
+
92
+ # Chainable method that allows you to get the previous page for a given before token
93
+ def previous_page(before_token)
94
+ clear
95
+ @options[:before] = before_token
96
+ self
97
+ end
98
+
99
+ def after_token
100
+ return nil if paging.nil?
101
+ return nil if paging[:cursors].nil?
102
+
103
+ paging[:cursors][:after]
104
+ end
105
+
106
+ def before_token
107
+ return nil if paging.nil?
108
+ return nil if paging[:cursors].nil?
109
+
110
+ paging[:cursors][:before]
111
+ end
112
+
113
+ def clear
114
+ @response = {}
115
+ end
116
+
117
+ def collection
118
+ @response = client.collection(resource_name, options)
119
+ end
120
+
121
+ def has_response?
122
+ response != {}
123
+ end
124
+
125
+ def symbolize_hash(hash)
126
+ Hash[hash.map{|(key,value)| [key.to_sym,value]}]
127
+ end
128
+ end
129
+ end
130
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RTX
2
4
  module API
3
5
  class Resources
6
+ # rubocop:disable Metrics/MethodLength
4
7
  def self.allowed_resources
5
8
  {
6
9
  accounts: 'accounts',
10
+ account_settings: 'account_settings',
7
11
  alerts: 'alerts',
8
12
  alert_frequencies: 'alert_frequencies',
9
13
  alert_types: 'alert_types',
@@ -18,11 +22,14 @@ module RTX
18
22
  layouts: 'layouts',
19
23
  locations: 'locations',
20
24
  notes: 'notes',
25
+ passwords: 'passwords',
21
26
  permissions: 'permissions',
27
+ plan_changes: 'plan_changes',
22
28
  profiles: 'profiles',
23
29
  requests: 'requests',
24
30
  request_pages: 'request_pages',
25
31
  request_types: 'request_types',
32
+ responses: 'responses',
26
33
  reviews: 'reviews',
27
34
  review_status_labels: 'review_status_labels',
28
35
  single_sign_ons: 'single_sign_ons',
@@ -33,9 +40,12 @@ module RTX
33
40
  urls: 'urls',
34
41
  users: 'users',
35
42
  user_types: 'user_types',
36
- whitelabels: 'whitelabels'
43
+ whitelabels: 'whitelabels',
44
+ v2_reviews: 'v2/reviews',
45
+ v2_reviews_csv: 'v2/reviews_csv'
37
46
  }.freeze
38
47
  end
48
+ # rubocop:enable Metrics/MethodLength
39
49
  end
40
50
  end
41
51
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RTX
2
4
  module API
3
- VERSION = "0.3.2"
5
+ VERSION = '0.5.0'
4
6
  end
5
7
  end
@@ -0,0 +1,18 @@
1
+ # Title
2
+ [Link to passing hydra (unless you're triggering through this PR)]
3
+
4
+ [Description]
5
+
6
+ #### Do you have tests for your changes?
7
+ - [ ] Yes
8
+ - [ ] No (if no, why not?)
9
+
10
+ # Proof
11
+
12
+ ## Before
13
+ [Attach prior behavior if applicable]
14
+
15
+ ## After
16
+ [Attach new behavior proof]
17
+
18
+ - [ ] Zach's Checkbox (aka: I've manually regression tested any large changes)
@@ -6,12 +6,11 @@ require 'rtx/api/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rtx-api"
8
8
  spec.version = RTX::API::VERSION
9
- spec.authors = ["ReviewTrackers Engineering"]
10
- spec.email = ["engineering@reviewtrackers.com"]
9
+ spec.authors = ["Review Trackers Engineering"]
10
+ spec.email = ["nate@reviewtrackers.com"]
11
11
 
12
12
  spec.summary = %q{Ruby Client for the Review Trackers RTX API.}
13
13
  spec.description = %q{A Ruby Client for the RTX API provided by Review Trackers.}
14
- spec.homepage = "https://github.com/reviewtrackers/rtx-api-client-ruby"
15
14
  spec.license = "MIT"
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -24,4 +23,6 @@ Gem::Specification.new do |spec|
24
23
  # add dependencies here. development dependencies should go into the Gemfile
25
24
  spec.add_dependency 'httparty'
26
25
  spec.add_dependency 'oj'
26
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
27
+ spec.add_development_dependency 'simplecov'
27
28
  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.3.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - ReviewTrackers Engineering
7
+ - Review Trackers Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-03 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,9 +38,37 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description: A Ruby Client for the RTX API provided by Review Trackers.
42
70
  email:
43
- - engineering@reviewtrackers.com
71
+ - nate@reviewtrackers.com
44
72
  executables: []
45
73
  extensions: []
46
74
  extra_rdoc_files: []
@@ -55,14 +83,16 @@ files:
55
83
  - lib/rtx/api.rb
56
84
  - lib/rtx/api/client.rb
57
85
  - lib/rtx/api/collection.rb
86
+ - lib/rtx/api/collection_v2.rb
58
87
  - lib/rtx/api/errors/authentication_error.rb
59
88
  - lib/rtx/api/errors/client_error.rb
60
89
  - lib/rtx/api/errors/invalid_resource_error.rb
61
90
  - lib/rtx/api/errors/request_error.rb
62
91
  - lib/rtx/api/resources.rb
63
92
  - lib/rtx/api/version.rb
93
+ - pull_request_template.md
64
94
  - rtx-api.gemspec
65
- homepage: https://github.com/reviewtrackers/rtx-api-client-ruby
95
+ homepage:
66
96
  licenses:
67
97
  - MIT
68
98
  metadata: {}
@@ -81,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
111
  - !ruby/object:Gem::Version
82
112
  version: '0'
83
113
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.5.1
114
+ rubygems_version: 3.1.1
86
115
  signing_key:
87
116
  specification_version: 4
88
117
  summary: Ruby Client for the Review Trackers RTX API.