zendesk-api 0.2.0 → 0.2.1

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.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('zendesk-api', '0.2.0') do |p|
5
+ Echoe.new('zendesk-api', '0.2.1') do |p|
6
6
  p.description = "RubyGem wrapper for REST API to http://zendesk.com"
7
7
  p.author = "Peter Ericson"
8
8
  p.url = "http://github.com/pgericson/zendesk-api"
data/lib/zendesk/main.rb CHANGED
@@ -7,6 +7,7 @@ module Zendesk
7
7
  @account = account
8
8
  @username = username
9
9
  @password = password
10
+ @options = options
10
11
  if options[:format] && ['xml','json'].any?{|f| f == options[:format]}
11
12
  @format = options[:format]
12
13
  else
@@ -15,7 +16,7 @@ module Zendesk
15
16
  end
16
17
 
17
18
  def main_url
18
- url_prefix = "http://"
19
+ url_prefix = @options[:ssl] ? "https://" : "http://"
19
20
  url_postfix = ".zendesk.com/"
20
21
  url = url_prefix + @account + url_postfix
21
22
  end
@@ -59,7 +60,32 @@ module Zendesk
59
60
  if curl.body_str == "<error>Couldn't authenticate you</error>"
60
61
  return "string" #raise CouldNotAuthenticateYou
61
62
  end
62
- curl.body_str
63
+ Response.new(curl)
64
+ end
65
+
66
+ class Response
67
+
68
+ attr_reader :status, :body, :headers_raw, :headers
69
+
70
+ def initialize(curl)
71
+ @status=curl.response_code
72
+ @body=curl.body_str
73
+ @headers_raw=curl.header_str
74
+ parse_headers
75
+ end
76
+
77
+ def parse_headers
78
+ hs={}
79
+ headers_raw.split("\r\n")[1..-1].each do |h|
80
+ # Rails.logger.info h
81
+ m=h.match(/([^:]+):\s?(.*)/)
82
+ next if m.nil? or m[2].nil?
83
+ # Rails.logger.info m.inspect
84
+ hs[m[1]]=m[2]
85
+ end
86
+ @headers=hs
87
+ end
88
+
63
89
  end
64
90
 
65
91
  include Zendesk::User
data/zendesk-api.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{zendesk-api}
5
- s.version = "0.2.0"
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Peter Ericson"]
9
- s.date = %q{2010-03-11}
9
+ s.date = %q{2010-03-19}
10
10
  s.description = %q{RubyGem wrapper for REST API to http://zendesk.com}
11
11
  s.email = %q{pg.ericson@gmail.com}
12
12
  s.extra_rdoc_files = ["README.markdown", "lib/console.rb", "lib/zendesk-api.rb", "lib/zendesk.rb", "lib/zendesk/attachment.rb", "lib/zendesk/entry.rb", "lib/zendesk/forum.rb", "lib/zendesk/group.rb", "lib/zendesk/main.rb", "lib/zendesk/organization.rb", "lib/zendesk/search.rb", "lib/zendesk/tag.rb", "lib/zendesk/ticket.rb", "lib/zendesk/user.rb"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Ericson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-11 00:00:00 +01:00
17
+ date: 2010-03-19 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20