quicktravel_client 4.2.0 → 4.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
2
  SHA256:
3
- metadata.gz: 91f206668887a5c5fae84eceedf3aff502b18e7fe9128c532f2945c1103e8d22
4
- data.tar.gz: 46897c6a9d0bf5934c1c6f0c9333c33ddce9d9e8412f8551a089c041f181ed8f
3
+ metadata.gz: e0325799c230cd8fe94a4f7454f8ff7ccb5fddb27ab18a67b9f3096d72aada02
4
+ data.tar.gz: 427ad145f755aa347c5ceb6d1c558b9e47392d1e61f48daeac074b933d7ded30
5
5
  SHA512:
6
- metadata.gz: 49878c0a691f3794d4fc840d81078099c5235f18845405e1bd1868f1737aec01e25bda51766ed020c27d2e95cb4086d2ddba6f854048c324e4da1b2ab7bb3bf2
7
- data.tar.gz: 31ab91f4e630f3d5a5e8c04a2ae159fab5a555ed937ecd1880a852955201b26e83f5a86659d31d36b9e68c502c31e0e69cd779f4290f7f850ed98ed436664d7b
6
+ metadata.gz: 744fc85a1f7bf032a494eb394c1573f06c0a1094608da175f7fc20c053babf78a8950bf038ff0b6dff97a0926f70492b96db2481083aa9055590f9fd8bdd33ac
7
+ data.tar.gz: 42f9a4aefc2150631c807a96bfaad03b8a0b6ff9c1427980435bd5a35818dadb84929b715199c47c2f02093be211b5f1565ef9957087129f5feed7398768bbae
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -0,0 +1,59 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ name: Build
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ bundler-cache: true
18
+ - run: bundle exec rake
19
+
20
+ release:
21
+ needs: build
22
+ name: Release
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - name: Checkout
26
+ uses: actions/checkout@v2
27
+
28
+ - name: Generate Changelog
29
+ run: |
30
+ # Get version from github ref (remove 'refs/tags/' and prefix 'v')
31
+ version="${GITHUB_REF#refs/tags/v}"
32
+ npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
33
+
34
+ - name: Release
35
+ uses: softprops/action-gh-release@v1
36
+ with:
37
+ body_path: ${{ github.workflow }}-CHANGELOG.txt
38
+ env:
39
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
+
41
+ publish:
42
+ needs: [build, release]
43
+ name: Publish
44
+ runs-on: ubuntu-latest
45
+
46
+ steps:
47
+ - uses: actions/checkout@v2
48
+ - uses: ruby/setup-ruby@v1
49
+
50
+ - name: Publish to RubyGems
51
+ run: |
52
+ mkdir -p $HOME/.gem
53
+ touch $HOME/.gem/credentials
54
+ chmod 0600 $HOME/.gem/credentials
55
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
56
+ gem build *.gemspec
57
+ gem push *.gem
58
+ env:
59
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,19 @@
1
+ name: Build and Test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ strategy:
6
+ fail-fast: false
7
+ matrix:
8
+ gemfile: [rails60, rails61]
9
+ ruby: ["2.6", "2.7", "3.0"]
10
+ runs-on: ubuntu-latest
11
+ env:
12
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler-cache: true
19
+ - run: bundle exec rake
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.0.0
data/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
5
5
 
6
+ ## Unreleased
7
+
8
+
9
+ ## 4.5.0
10
+ - [TT-9346] Support injection of additional headers in requests to quicktravel
11
+ - [TT-9331] Cache resources to reduce unnecessary API requests
12
+
13
+ ## 4.4.0
14
+ - [TT-8615] Update to build with github actions / ruby 3.0 / rails 6.1
15
+
16
+ ## [4.3.2]
17
+ ### Fixed
18
+ - [TT-8511] Revert party lookup via the API endpoint
19
+
20
+ ## [4.3.1]
21
+ ### Fixed
22
+ - [TT-8471] Fix missing QuickTravel:VERSION const error
23
+
24
+ ## [4.3.0]
25
+ ### Changed
26
+ - [TT-8142] Add suitable user-agent header
27
+ - [TT-8379] Switch to using api/parties endpoint
28
+
6
29
  ## [4.2.0]
7
30
  ### Changed
8
31
  - [TT-7969] Update cassettes to work with HttpParty >= 0.18.1
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
- QuickTravel
2
- ===========
1
+ # QuickTravel
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/quicktravel_client.svg)](http://badge.fury.io/rb/quicktravel_client)
5
- [![Build Status](https://travis-ci.org/sealink/quicktravel_client.svg?branch=master)](https://travis-ci.org/sealink/quicktravel_client)
4
+ [![Build Status](https://github.com/sealink/quicktravel_client/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/sealink/quicktravel_client/actions)
6
5
  [![Coverage Status](https://coveralls.io/repos/sealink/quicktravel_client/badge.svg)](https://coveralls.io/r/sealink/quicktravel_client)
7
- [![Dependency Status](https://gemnasium.com/sealink/quicktravel_client.svg)](https://gemnasium.com/sealink/quicktravel_client)
8
6
  [![Code Climate](https://codeclimate.com/github/sealink/quicktravel_client/badges/gpa.svg)](https://codeclimate.com/github/sealink/quicktravel_client)
9
7
 
10
8
  # DESCRIPTION
@@ -14,17 +12,38 @@ Gives models that are integrated with the QuickTravel API
14
12
  # INSTALLATION
15
13
 
16
14
  Add to your Gemfile:
15
+
16
+ ```
17
17
  gem 'quicktravel_client'
18
+ ```
18
19
 
19
20
  # REGENERATE CASSETTES
20
21
 
21
22
  In QuickTravel:
23
+ ```
22
24
  mysql quicktravel_test < ../quicktravel_test/bootstrap.sql
23
25
  TIMECOP=1 WEBMOCK=0 QUICKTRAVEL_CONFIG_DIR=spec/support/config RAILS_ENV=test bundle exec rails s -p8080
26
+ ```
24
27
 
25
28
  In Payment Service: (if needing to generate checkout cassettes):
29
+ ```
26
30
  bundle exec puma -Ilib -p7000
31
+ ```
27
32
 
28
33
  In QuickTravel Client:
34
+ ```
29
35
  rm spec/support/cassettes/ -rf
30
36
  QT_KEYS=a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2,1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a bundle exec rspec
37
+ ```
38
+
39
+ # RELEASE
40
+
41
+ To publish a new version of this gem the following steps must be taken.
42
+
43
+ * Update the version in the following files
44
+ ```
45
+ CHANGELOG.md
46
+ lib/quick_travel/version.rb
47
+ ````
48
+ * Create a tag using the format v0.1.0
49
+ * Follow build progress in GitHub actions
File without changes
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+ gemspec :path => '../'
3
+
4
+ group :development, :test do
5
+ gem 'activesupport', '~> 6.1'
6
+ gem 'activerecord', '~> 6.1'
7
+ gem 'actionpack', '~> 6.1'
8
+ end
@@ -9,6 +9,7 @@ require 'facets/hash/delete_values'
9
9
  require 'quick_travel/config'
10
10
  require 'quick_travel/adapter_error'
11
11
  require 'quick_travel/init_from_hash'
12
+ require 'quick_travel/version'
12
13
 
13
14
  module QuickTravel
14
15
  class Adapter
@@ -214,6 +215,9 @@ module QuickTravel
214
215
  http_params[:headers] ||= {}
215
216
  http_params[:headers]['Content-length'] = '0' if http_params[:body].blank?
216
217
  http_params[:headers]['x-api-key'] = QuickTravel.config.access_key
218
+ http_params[:headers]['user-agent'] = 'quicktravel_client/' + QuickTravel::VERSION;
219
+ http_params[:headers].merge!(extra_headers) if extra_headers
220
+
217
221
  expect = http_params.delete(:expect)
218
222
 
219
223
  # Use :body instead of :query for put/post.
@@ -251,6 +255,10 @@ module QuickTravel
251
255
  response
252
256
  end
253
257
 
258
+ def self.extra_headers
259
+ QuickTravel.config.extra_headers
260
+ end
261
+
254
262
  # Do standard validations on response
255
263
  #
256
264
  # Firstly, check if a valid HTTP code was returned
@@ -2,7 +2,7 @@ require 'quick_travel/adapter'
2
2
 
3
3
  module QuickTravel
4
4
  class Configuration
5
- attr_accessor :url, :access_key, :version
5
+ attr_accessor :url, :access_key, :version, :extra_headers
6
6
 
7
7
  def url=(url)
8
8
  @url = url
@@ -7,9 +7,10 @@ module QuickTravel
7
7
 
8
8
  def initialize(hash = {})
9
9
  super
10
- if type.blank?
11
- @type = 'Person'
12
- end
10
+ # TODO Fix the QT endpoint to actual return the type, first step
11
+ # is to revert it so we can fix the pacts, than we can update the
12
+ # expectations to include a return value
13
+ @type = 'Person'
13
14
  end
14
15
 
15
16
  self.api_base = '/parties'
@@ -18,6 +19,10 @@ module QuickTravel
18
19
  get_and_validate('/parties/find_by_login.json', options)
19
20
  end
20
21
 
22
+ def self.create(options = {})
23
+ post_and_validate("/api/parties.json", options)
24
+ end
25
+
21
26
  # Asks QuickTravel to check the credentials
22
27
  #
23
28
  # @returns: Party: Valid Credentials
@@ -11,6 +11,11 @@ module QuickTravel
11
11
  Resource.find_all!('/api/resources.json', parent_resource_id: @id)
12
12
  end
13
13
 
14
+ def self.find(id, opts = {})
15
+ opts = { cache_key: "resource:#{id}", cache_options: { expires_in: 1.hour } }.merge(opts)
16
+ super(id, opts)
17
+ end
18
+
14
19
  def self.all_with_price(opts)
15
20
  cache_key = GenerateCacheKey.new(name, opts).call
16
21
  find_all!("/api/resources/index_with_price.json", opts.merge(cache_key: cache_key))
@@ -1,3 +1,3 @@
1
1
  module QuickTravel
2
- VERSION = '4.2.0'
2
+ VERSION = '4.5.0'
3
3
  end
@@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ['lib']
18
+ spec.required_ruby_version = '>= 2.6'
18
19
 
19
20
  spec.add_dependency 'httparty', '>= 0.18.1'
20
21
  spec.add_dependency 'activesupport', '>= 5.0.0'
@@ -34,5 +35,5 @@ Gem::Specification.new do |spec|
34
35
  spec.add_development_dependency 'vcr'
35
36
  spec.add_development_dependency 'webmock'
36
37
  spec.add_development_dependency 'rubocop'
37
- spec.add_development_dependency 'travis'
38
+ spec.add_development_dependency 'pry'
38
39
  end
data/spec/adapter_spec.rb CHANGED
@@ -83,4 +83,28 @@ describe QuickTravel::Adapter do
83
83
  specify { expect(api).to have_received(:call_and_validate).twice }
84
84
  end
85
85
  end
86
+
87
+ context 'extra headers defined' do
88
+ let(:url) { 'http://test.quicktravel.com.au' }
89
+ let(:query) { {} }
90
+ let(:change_config) { }
91
+ let(:useragent) { 'rspec' }
92
+
93
+ before do
94
+ change_config
95
+ QuickTravel::Adapter.post_and_validate(url, query)
96
+ end
97
+
98
+ let(:expected_params) { a_hash_including(headers: a_hash_including('user-agent' => useragent)) }
99
+
100
+ specify { expect(QuickTravel::Api).to have_received(:post).with(url, expected_params) }
101
+
102
+ context 'and the config is changed' do
103
+ let(:useragent) { 'newspec' }
104
+ let(:change_config) {
105
+ QuickTravel.config.extra_headers = { 'user-agent' => 'newspec' }
106
+ }
107
+ specify { expect(QuickTravel::Api).to have_received(:post).with(url, expected_params) }
108
+ end
109
+ end
86
110
  end
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ qt_keys = ENV['QT_KEYS'].split(',')
22
22
  QuickTravel.configure do |c|
23
23
  c.url = 'http://test.qt.sealink.com.au:8080'
24
24
  c.access_key = qt_keys[0]
25
+ c.extra_headers = { 'user-agent' => 'rspec' }
25
26
  end
26
27
 
27
28
  require 'quick_travel/connection_error'
@@ -1,4 +1,4 @@
1
1
  require 'simplecov-rcov'
2
2
  require 'coveralls'
3
3
  require 'coverage/kit'
4
- Coverage::Kit.setup(minimum_coverage: 83.2)
4
+ Coverage::Kit.setup(minimum_coverage: 83.7)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quicktravel_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-09-11 00:00:00.000000000 Z
13
+ date: 2021-05-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -251,7 +251,7 @@ dependencies:
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  - !ruby/object:Gem::Dependency
254
- name: travis
254
+ name: pry
255
255
  requirement: !ruby/object:Gem::Requirement
256
256
  requirements:
257
257
  - - ">="
@@ -270,11 +270,13 @@ executables: []
270
270
  extensions: []
271
271
  extra_rdoc_files: []
272
272
  files:
273
+ - ".github/dependabot.yml"
274
+ - ".github/workflows/release.yml"
275
+ - ".github/workflows/ruby.yml"
273
276
  - ".gitignore"
274
277
  - ".rspec"
275
278
  - ".rubocop.yml"
276
279
  - ".ruby-version"
277
- - ".travis.yml"
278
280
  - CHANGELOG.md
279
281
  - Gemfile
280
282
  - LICENSE
@@ -282,8 +284,8 @@ files:
282
284
  - Rakefile
283
285
  - examples/example_config.rb
284
286
  - examples/login_example.rb
285
- - gemfiles/rails5.gemfile
286
- - gemfiles/rails6.gemfile
287
+ - gemfiles/rails60.gemfile
288
+ - gemfiles/rails61.gemfile
287
289
  - lib/extensions.rb
288
290
  - lib/quick_travel.rb
289
291
  - lib/quick_travel/accommodation.rb
@@ -450,14 +452,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
450
452
  requirements:
451
453
  - - ">="
452
454
  - !ruby/object:Gem::Version
453
- version: '0'
455
+ version: '2.6'
454
456
  required_rubygems_version: !ruby/object:Gem::Requirement
455
457
  requirements:
456
458
  - - ">="
457
459
  - !ruby/object:Gem::Version
458
460
  version: '0'
459
461
  requirements: []
460
- rubygems_version: 3.1.2
462
+ rubygems_version: 3.2.3
461
463
  signing_key:
462
464
  specification_version: 4
463
465
  summary: Booking process using QuickTravel API
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5
4
- - 2.6
5
- - 2.7
6
- before_install:
7
- - gem install bundler
8
- script: bundle && bundle exec rspec spec
9
- gemfile:
10
- - gemfiles/rails5.gemfile
11
- - gemfiles/rails6.gemfile
12
- notifications:
13
- email:
14
- - support@travellink.com.au
15
- sudo: false
16
- cache: bundler
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec :path => '../'
3
-
4
- group :development, :test do
5
- gem 'activesupport', '~> 5.0'
6
- gem 'activerecord', '~> 5.0'
7
- gem 'actionpack', '~> 5.0'
8
- end