dawanda_client 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gems ADDED
@@ -0,0 +1 @@
1
+ dawanda_client
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dawanda_client}
8
- s.version = "0.1.10"
8
+ s.version = "0.1.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["DaWanda GmbH"]
12
- s.date = %q{2010-03-16}
12
+ s.date = %q{2010-03-23}
13
13
  s.description = %q{Provides a friendly ruby-like interface to the Dawanda API}
14
14
  s.email = %q{api@dawanda.com}
15
15
  s.extra_rdoc_files = [
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
17
17
  "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
- "LICENSE",
20
+ ".gems",
21
+ "LICENSE",
21
22
  "README.rdoc",
22
23
  "Rakefile",
23
24
  "VERSION",
24
- "config.ru",
25
25
  "dawanda_client.gemspec",
26
26
  "lib/dawanda.rb",
27
27
  "lib/dawanda/category.rb",
data/lib/dawanda.rb CHANGED
@@ -82,6 +82,17 @@ module Dawanda
82
82
  @domain || 'dawanda.com'
83
83
  end
84
84
 
85
+ # retrieve HTTP Basic credentials
86
+ def self.http_basic
87
+ @http_basic || nil
88
+ end
89
+
90
+ # set credetials for HTTP Basic Authentification
91
+ # like: Dawanda.http_basic = {:user => 'myusername', :password => 'mypassword'}
92
+ def self.http_basic= credentials=nil
93
+ @http_basic = credentials
94
+ end
95
+
85
96
  # Find a user by username. See Dawanda::User for more information.
86
97
  def self.user(username_or_id, options={})
87
98
  User.find_by_user_id(username_or_id, options)
@@ -15,7 +15,6 @@ module Dawanda
15
15
  # A Response object with the payload data
16
16
  #
17
17
  def self.get(resource_path, parameters = {})
18
- parameters = {:format => 'json'}.update(parameters)
19
18
  request = Request.new(resource_path, parameters)
20
19
  Response.new(request.get)
21
20
  end
@@ -29,7 +28,11 @@ module Dawanda
29
28
  # Perform a GET request against the API endpoint and return the raw
30
29
  # response data
31
30
  def get
32
- response = Net::HTTP.get_response(endpoint_uri)
31
+ request = Net::HTTP::Get.new endpoint_uri.path
32
+ request.basic_auth Dawanda.http_basic[:user], Dawanda.http_basic[:password] if Dawanda.http_basic
33
+ request.set_form_data parameters
34
+ response = Net::HTTP.new(endpoint_uri.host, endpoint_uri.port).start {|http| http.request(request) }
35
+
33
36
  case response
34
37
  when Net::HTTPSuccess, Net::HTTPRedirection
35
38
  return response.body
@@ -39,17 +42,11 @@ module Dawanda
39
42
  end
40
43
 
41
44
  def parameters # :nodoc:
42
- @parameters.merge(:api_key => Dawanda.api_key)
43
- end
44
-
45
- def query # :nodoc:
46
- parameters.map {|k,v| "#{k}=#{v}"}.join('&')
45
+ @parameters.merge(:api_key => Dawanda.api_key, :format => 'json')
47
46
  end
48
47
 
49
48
  def endpoint_uri # :nodoc:
50
- uri = URI.parse("#{self.class.base_url}#{@resource_path}")
51
- uri.query = query
52
- uri
49
+ URI.parse("#{self.class.base_url}#{@resource_path}")
53
50
  end
54
51
  end
55
- end
52
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 10
9
- version: 0.1.10
8
+ - 11
9
+ version: 0.1.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - DaWanda GmbH
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-16 00:00:00 +01:00
17
+ date: 2010-03-23 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -28,11 +28,11 @@ extra_rdoc_files:
28
28
  - LICENSE
29
29
  - README.rdoc
30
30
  files:
31
+ - .gems
31
32
  - LICENSE
32
33
  - README.rdoc
33
34
  - Rakefile
34
35
  - VERSION
35
- - config.ru
36
36
  - dawanda_client.gemspec
37
37
  - lib/dawanda.rb
38
38
  - lib/dawanda/category.rb
data/config.ru DELETED
@@ -1,3 +0,0 @@
1
- require "lib/dawanda.rb"
2
- require "examples/shop/shop.rb"
3
- run Sinatra::Application