hotdogprincess 0.2.2 → 0.3.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
  SHA1:
3
- metadata.gz: e44d5b270248f910c06e9b3697a83a4f82d60ae5
4
- data.tar.gz: 18d0bba904a3111874cbcb2e2037ea793d580f4a
3
+ metadata.gz: b5098121aaf05769fa7d92fe52495805f1466010
4
+ data.tar.gz: 4b6e03266eac8930d581ebd20d2c61f6f0e5230b
5
5
  SHA512:
6
- metadata.gz: c6a4e61783e05149ed10fa430c93bb571445cd0a3760a9a36c8d8d84e55ff9914642213b60c836dcdb793b7beca4645e221b64e15defbdcd3f09cf3fc1b2bfa4
7
- data.tar.gz: b9b0bafe6a5c5a3d0f8628289563df9e7ef0b2fd13e2a90564efc1945050de0bbe89c543e4cd7ec627431fba14c9f949b60db7d2c99b25632f8624486afa80e6
6
+ metadata.gz: 4b1cc8fea3b22a94352c0b059cf1accefe3214753713547925adec344bfd3be75c36ebe99da179479bd96b492521c992b8e1619ec386dec77123b2624051d4ea
7
+ data.tar.gz: 13a5d57a85f5494ee136ddd9e69712613350ae4a3ea435d33e8eadda9cc187238d8311f62261a442b21f2941bdc36c04107de5195594c563fe90e112dc699663
data/README.md CHANGED
@@ -6,7 +6,10 @@ _-- "Their message says, Baby... Us... Trouble... Time."_
6
6
 
7
7
  Integrate with the [Parature](http://www.parature.com/) API. It's gunna be so flippin' awesome!
8
8
 
9
- Currently a WIP.
9
+ ## Current Modules Supported
10
+ - Customers
11
+ - SLAs
12
+ - Tickets
10
13
 
11
14
  ## Installation
12
15
 
@@ -312,6 +315,10 @@ client.get 'Customer', "First_Name_like_" => "joe"
312
315
  => {"?xml"=>{"@version"=>"1.0", "@encoding"=>"utf-8"}...
313
316
  ```
314
317
 
318
+ ## Notes
319
+
320
+ - Nil values are stripped from hashes to be used, Parature does not accept the `xsi:nil` values.
321
+
315
322
  ## Contributing
316
323
 
317
324
  1. Fork it
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency 'gyoku', '~> 1'
22
22
  spec.add_runtime_dependency 'nori', '~> 2'
23
+ spec.add_runtime_dependency 'rest-client'
23
24
 
24
25
  spec.require_paths = ['lib']
25
26
  spec.required_ruby_version = '>= 1.9.2'
@@ -62,6 +62,8 @@ module HotDogPrincess
62
62
 
63
63
  customer = get "Customer/#{new_customer_xml['Customer']['@id']}", _history_: false
64
64
 
65
+ return unless customer and customer['Customer']
66
+
65
67
  parse_customer customer['Customer']
66
68
  end
67
69
 
@@ -62,6 +62,8 @@ module HotDogPrincess
62
62
 
63
63
  ticket = get "Ticket/#{new_ticket_xml['Ticket']['@id']}", _history_: false
64
64
 
65
+ return unless ticket and ticket['Ticket']
66
+
65
67
  parse_ticket ticket['Ticket']
66
68
  end
67
69
 
@@ -3,6 +3,7 @@ require "hotdogprincess/version"
3
3
  require "hotdogprincess/client/customers"
4
4
  require "hotdogprincess/client/tickets"
5
5
  require "hotdogprincess/client/slas"
6
+ require 'hotdogprincess/error'
6
7
 
7
8
  module HotDogPrincess
8
9
 
@@ -26,7 +27,11 @@ module HotDogPrincess
26
27
  _output_: @output_format,
27
28
  _token_: @token
28
29
  }.merge(options)
29
- @last_response = RestClient.get url, { params: options }
30
+ begin
31
+ @last_response = RestClient.get url, { params: options }
32
+ rescue => e
33
+ raise HotDogPrincess::Error.new(e.response, self)
34
+ end
30
35
  clean_response @last_response
31
36
  end
32
37
 
@@ -35,7 +40,11 @@ module HotDogPrincess
35
40
  options = {
36
41
  content_type: :xml
37
42
  }.merge(options)
38
- @last_response = RestClient.post url, body, options
43
+ begin
44
+ @last_response = RestClient.post url, body, options
45
+ rescue => e
46
+ raise HotDogPrincess::Error.new(e.response, self)
47
+ end
39
48
  @last_response
40
49
  end
41
50
 
@@ -44,7 +53,11 @@ module HotDogPrincess
44
53
  options = {
45
54
  content_type: :xml
46
55
  }.merge(options)
47
- @last_response = RestClient.put url, body, options
56
+ begin
57
+ @last_response = RestClient.put url, body, options
58
+ rescue => e
59
+ raise HotDogPrincess::Error.new(e.response, self)
60
+ end
48
61
  @last_response
49
62
  end
50
63
 
@@ -54,7 +67,11 @@ module HotDogPrincess
54
67
  _output_: @output_format,
55
68
  _token_: @token
56
69
  }.merge(options)
57
- @last_response = RestClient.delete url, { params: options }
70
+ begin
71
+ @last_response = RestClient.delete url, { params: options }
72
+ rescue => e
73
+ raise HotDogPrincess::Error.new(e.response, self)
74
+ end
58
75
  @last_response
59
76
  end
60
77
 
@@ -0,0 +1,23 @@
1
+ module HotDogPrincess
2
+ class CoreExtensions
3
+ module Hash
4
+
5
+ def compact
6
+ # inject({}) do |new_hash, (k, v)|
7
+ # if !v.nil?
8
+ # new_hash[k] = v.class == Hash ? v.compact : v
9
+ # end
10
+ # new_hash
11
+ # end
12
+ delete_if { |k, v|
13
+ (v.is_a?(Hash) and v.respond_to?('empty?') and v.compact.empty?) or (v.nil?)
14
+ }
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+
21
+ class Hash
22
+ include HotDogPrincess::CoreExtensions::Hash
23
+ end
@@ -1,6 +1,7 @@
1
1
  require "restclient"
2
2
  require "hotdogprincess/version"
3
3
  require "hotdogprincess/core_extensions/string"
4
+ require "hotdogprincess/core_extensions/hash"
4
5
 
5
6
  module HotDogPrincess
6
7
  class CoreExtensions
@@ -0,0 +1,9 @@
1
+ module HotDogPrincess
2
+ class Error < StandardError
3
+ attr_accessor :object
4
+ def initialize(message = nil, object = nil)
5
+ super(message)
6
+ self.object = object
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module HotDogPrincess
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'hotdogprincess/client'
2
+ require 'hotdogprincess/error'
2
3
  require 'hotdogprincess/core_extensions'
3
4
 
4
5
  module HotDogPrincess
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdogprincess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Callis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-22 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Integrate with the Parature API.
56
70
  email:
57
71
  - matthew.callis@gmail.com
@@ -69,7 +83,9 @@ files:
69
83
  - lib/hotdogprincess/client/slas.rb
70
84
  - lib/hotdogprincess/client/tickets.rb
71
85
  - lib/hotdogprincess/core_extensions.rb
86
+ - lib/hotdogprincess/core_extensions/hash.rb
72
87
  - lib/hotdogprincess/core_extensions/string.rb
88
+ - lib/hotdogprincess/error.rb
73
89
  - lib/hotdogprincess/version.rb
74
90
  homepage: https://github.com/MatthewCallis/hotdogprincess
75
91
  licenses:
@@ -91,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
107
  version: 1.3.5
92
108
  requirements: []
93
109
  rubyforge_project:
94
- rubygems_version: 2.4.1
110
+ rubygems_version: 2.4.2
95
111
  signing_key:
96
112
  specification_version: 4
97
113
  summary: Integrate with the Parature API. It's gunna be so flippin' awesome!