apipie-postman 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/apipie-postman.rb +14 -12
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b51cef8c7fc976fc2ccc65adea1a7a310e78a88f13012da523513e569daa6d0
4
- data.tar.gz: 270436badcf392d477d9a1ac1f734a5443a6ef2d6a34b1866fe230c0357c2075
3
+ metadata.gz: 744c898d34eba39938c8961bbfa6047b26e75cec9ef9b46bdd9571622cd626d2
4
+ data.tar.gz: 53d9f075566802e40802aeae23187747f88c50342b5d496584cc75c2d727038e
5
5
  SHA512:
6
- metadata.gz: 7bd3da97802ae8f63790df791660075b51f165f9a941dbf29402a5d6f4dea6d3c89439e5460eb2356635bd1ca42432d378cc712eb22e07f936a48e6d944b566a
7
- data.tar.gz: 43627d5c8b2c6cebbe592592e2fc181e2fc8bf57ffdf694af7dcbfe944458521350e9cad7328a37e03a167f88b4a8489e2e118761d9c41df18595db016d04a49
6
+ metadata.gz: 55bf9987fd1e88cc716bc8a57ad095f114da7c4ed957c98e5664a7d92dfd4b60bbc666d7eb64dcb1dbdc69f208f6110bc2ffcbdc7e91f4ab683a3b72dcedba76
7
+ data.tar.gz: bc1b255a5fd737ecd73f0c10b793cce9de2ff4d975b30549eb329928c6a58023d3b8e8e071aa878de86dac0011beb2c8976f367d627b69a507f647a8b6109541
@@ -3,7 +3,6 @@
3
3
  require 'json'
4
4
  require 'faraday'
5
5
 
6
- # General module for gem
7
6
  module ApipiePostman
8
7
  class << self
9
8
  attr_accessor :configuration
@@ -46,7 +45,7 @@ module ApipiePostman
46
45
  end
47
46
 
48
47
  endpoints_hashes << {
49
- name: endpoint['title'],
48
+ name: endpoint['title'] == 'Default' ? "#{endpoint['verb']} #{endpoint['path']}" : endpoint['title'],
50
49
  request: {
51
50
  url: "#{self.configuration.base_url}#{endpoint['path']}",
52
51
  method: endpoint['verb'],
@@ -72,22 +71,25 @@ module ApipiePostman
72
71
  item: endpoints_hashes
73
72
  }
74
73
  }.to_json
74
+
75
75
  headers = {
76
76
  'X-Api-Key': self.configuration.postman_api_key,
77
77
  'Content-Type': 'application/json'
78
78
  }
79
79
 
80
- Faraday.public_send(:post, 'https://api.getpostman.com/collections/', body, headers)
80
+ collection_uid = check_collection_uid_by_name(headers)
81
81
 
82
- # if Object.const_defined?('POSTMAN_COLLECTION_UID') && Object.const_defined?('POSTMAN_COLLECTION_ID')
83
- # Faraday.public_send(:put, "https://api.getpostman.com/collections/#{Object.const_get('POSTMAN_COLLECTION_UID')}", body, headers)
84
- # else
85
- # response = Faraday.public_send(:post, 'https://api.getpostman.com/collections/', body, headers)
82
+ if collection_uid.nil?
83
+ Faraday.public_send(:post, 'https://api.getpostman.com/collections/', body, headers)
84
+ else
85
+ Faraday.public_send(:put, "https://api.getpostman.com/collections/#{collection_uid['uid']}", body, headers)
86
+ end
87
+ end
86
88
 
87
- # if response.status == 200
88
- # Object.const_set('POSTMAN_COLLECTION_UID', JSON.parse(response.body)['collection']['uid'])
89
- # Object.const_set('POSTMAN_COLLECTION_ID', JSON.parse(response.body)['collection']['id'])
90
- # end
91
- # end
89
+ def self.check_collection_uid_by_name(headers)
90
+ response = Faraday.public_send(:get, 'https://api.getpostman.com/collections/', {}, headers)
91
+ JSON.parse(response.body)['collections'].select do |col|
92
+ col['name'] == self.configuration.postman_collection_name
93
+ end.last
92
94
  end
93
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-postman
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
  - Victor Motogna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-25 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -59,7 +59,7 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.10'
61
61
  description: Use 'bundle exec apipie-postman' and 'rake apipie_postman' to generate
62
- the docs! More details on https://github.com/VictorMotogna/apipie-postman
62
+ the docs!
63
63
  email: vmotogna@gmail.com
64
64
  executables:
65
65
  - apipie-postman