itrp-client 1.0.1 → 1.0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTE5ZTY5ZDBkMWRhMDdkNjI5N2Q3MzY2NzQ1MTcwMTQ0NTljMzY5MA==
4
+ NDBlZmJiM2E5MjRkOGE4NWQ1YmQ3YTM0Njg1Nzk1ZmI4ZGI4YWY2YQ==
5
5
  data.tar.gz: !binary |-
6
- YTUwY2ZhOTc3OTU1ZjFlNmQyOGQ3Y2RjNDAxZDlkOGU1NmRmNmUxNQ==
6
+ ZDEyYThlYjgyZDkxZTAxZTA3Y2ExMTc5ZWYyZWM2YzQyNmQ1MThkMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWU1YjY1OWI0NWY2ODRlZWE1N2U1NjUwMWE3NzI0NDg5MTM1MDU0ZmQ0OTNh
10
- YTIwMzY0NDhiZDBiYzhiMjU5M2M5MmFkZDUwODY5MjhkNDM5Y2U3NDlmODA4
11
- YzhhOTVhZWU2YjI3ODQyY2YyNjI1YTE0M2ZkNTZkZmU1NzQwYjY=
9
+ NjllNDM3ODZkODU5OWI4NTliZDQxNzg4N2QwODM1MDJhN2I2MTNkY2EzM2Y0
10
+ ODZkMDVhYjhmYTMzMDkyNTJlMGViMzM1MDE1M2Y2ZDFkNTQyYzBlMjJlNzdi
11
+ MDUzYjc4ZTdkNTMzZGI2OTIyMzM5NTU3N2YzOWEzYjZmZmVkYWI=
12
12
  data.tar.gz: !binary |-
13
- MjdjNTc3NjIzYWY2M2Y0OWZmNzgzZTU2ZTQ3ZjNjMjVkZjQ0NjE2MWFhMWNm
14
- ZmQwNTk3MWQyOGY3NjQxZWI3YWYwMTkwZDA0NTk1ODIwMjdjZjYyMDdmZDFk
15
- NDE5ZmQzMDBhMTljMmE1Yjc3M2FkMjZjNDE3MjNkNGQzZTRmNDM=
13
+ NzFkYzY5OTEzMzJlNzE3MGYwOTdlYjAyMWMxMTE3M2YwYjMxN2IyNGJmMDBj
14
+ MzYyYjgxMDhkYjI0ZjQyMTBjNTllNWFlNjY0YTY5OWIxZWZjZTIwODhiNWJl
15
+ N2RjMjExZTJkMjJmOTI0MjA2ZjRjMzllMDljYzY4OGJmYmEzYTk=
@@ -15,13 +15,13 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = %q{http://github.com/itrp/itrp-client}
16
16
  spec.license = "MIT"
17
17
 
18
- spec.files = Dir.glob("lib/**/*") + [
19
- "LICENSE.txt",
20
- "README.md",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "itrp-client.gemspec"
24
- ]
18
+ spec.files = Dir.glob("lib/**/*") + %w(
19
+ LICENSE.txt
20
+ README.md
21
+ Gemfile
22
+ Gemfile.lock
23
+ itrp-client.gemspec
24
+ )
25
25
  spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
26
  spec.test_files = `git ls-files -- {test,spec}/*`.split("\n")
27
27
  spec.require_paths = ["lib"]
@@ -146,7 +146,13 @@ module Itrp
146
146
  data = {type: [types].flatten.join(',')}
147
147
  data[:from] = from unless from.blank?
148
148
  response = post('/export', data)
149
- @logger.info { "Export for '#{data[:type]}' successfully queued with token '#{response[:token]}'." } if response.valid?
149
+ if response.valid?
150
+ if response.raw.code.to_s == '204'
151
+ @logger.info { "No changed records for '#{data[:type]}' since #{data[:from]}." }
152
+ return response
153
+ end
154
+ @logger.info { "Export for '#{data[:type]}' successfully queued with token '#{response[:token]}'." }
155
+ end
150
156
 
151
157
  if block_until_completed
152
158
  raise ::Itrp::UploadFailed.new("Failed to queue '#{data[:type]}' export. #{response.message}") unless response.valid?
@@ -19,11 +19,22 @@ module Itrp
19
19
  report_error("Attachments not allowed for #{path}", raise_exceptions) and return unless storage
20
20
 
21
21
  # upload each attachment and store the {key, filesize} has in the note_attachments parameter
22
- data[:note_attachments] = attachments.map {|attachment| upload_attachment(storage, attachment, raise_exceptions) }.compact.to_json
22
+ data[attachments_field(path)] = attachments.map {|attachment| upload_attachment(storage, attachment, raise_exceptions) }.compact.to_json
23
23
  end
24
24
 
25
25
  private
26
26
 
27
+ def attachments_field(path)
28
+ case path
29
+ when /cis/, /contracts/, /flsas/, /service_instances/, /slas/
30
+ :remarks_attachments
31
+ when /service_offerings/
32
+ :summary_attachments
33
+ else
34
+ :note_attachments
35
+ end
36
+ end
37
+
27
38
  def report_error(message, raise_exceptions)
28
39
  if raise_exceptions
29
40
  raise Itrp::UploadFailed.new(message)
@@ -96,4 +107,4 @@ module Itrp
96
107
  end
97
108
 
98
109
  end
99
- end
110
+ end
@@ -22,8 +22,13 @@ module Itrp
22
22
  # If the response is not +valid?+ it is a Hash with 'message' and optionally 'errors'
23
23
  def json
24
24
  return @json if defined?(@json)
25
- # no body, no json
26
- data = {message: @response.message.blank? ? 'empty body' : @response.message.strip} if @response.body.blank?
25
+ # no content, no JSON
26
+ if @response.code.to_s == '204'
27
+ data = {}
28
+ elsif @response.body.blank?
29
+ # no body, no json
30
+ data = {message: @response.message.blank? ? 'empty body' : @response.message.strip}
31
+ end
27
32
  begin
28
33
  data ||= JSON.parse(@response.body)
29
34
  rescue ::Exception => e
@@ -1,5 +1,5 @@
1
1
  module Itrp
2
2
  class Client
3
- VERSION = "1.0.1"
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itrp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITRP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config