apipie-postman 0.0.4 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/apipie-postman.rb +14 -12
  3. metadata +11 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87a9d10c4744097a3ce9db04e23b892b59685b2305cc3b8b9d90411362a41ab2
4
- data.tar.gz: ffb57dc63728c8be8136ffe64b969a7cbfb52c2ca75efa217a039766e0626d80
3
+ metadata.gz: 744c898d34eba39938c8961bbfa6047b26e75cec9ef9b46bdd9571622cd626d2
4
+ data.tar.gz: 53d9f075566802e40802aeae23187747f88c50342b5d496584cc75c2d727038e
5
5
  SHA512:
6
- metadata.gz: bbe31d7a03653510182c88ae61296a7a6f296b66053222bac1cfd66ceca409a49c494ae22464ad11f2d95ef0376f23d32465dd8ecf0f5f0a590c8fc5de163195
7
- data.tar.gz: 8372022fb7976dcacdf4a8ba5e56f4279cc6a0b47e2d423b3e56bb84c118922387cb8c8a48ec0b79efade7a177c2759ca7a12e7474b98820549a2c593dab0c04
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,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-postman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
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-17 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
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.4'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 1.4.3
19
+ version: 1.0.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.4'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 1.4.3
29
+ version: 1.0.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pry
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -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