centro-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,12 +11,9 @@ Usage
11
11
 
12
12
  Start by creating a connection to Centro with your credentials:
13
13
 
14
- require 'centro-centro'
14
+ require 'centro-client'
15
15
 
16
- centro = Centro::API.new(:api_key => API_KEY)
17
-
18
- NOTE: You can leave out the `:api_key` if `ENV['CENTRO_API_KEY']` is set
19
- instead.
16
+ centro = Centro::Client.new(:access_token => ACCESS_TOKEN)
20
17
 
21
18
  Now you can make requests to the api.
22
19
 
@@ -33,17 +30,10 @@ Mock
33
30
 
34
31
  For practice or testing you can also use a simulated Centro:
35
32
 
36
- require 'centro-api'
33
+ require 'centro-client'
37
34
 
38
- centro = Centro::API.new(:api_key => API_KEY, :mock => true)
35
+ centro = Centro::Client.new(:access_token => ACCESS_TOKEN, :mock => true)
39
36
 
40
37
  After that commands should still behave the same, but they will only
41
38
  modify some local data instead of updating the state of things on
42
39
  Centro.
43
-
44
- Tests
45
- -----
46
-
47
- To run tests, first set `ENV['CENTRO_API_KEY']` to your api key. Then
48
- use `bundle exec rake` to run mock tests or `MOCK=false bundle exec
49
- rake` to run integration tests.
@@ -25,4 +25,5 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency 'omniauth-oauth2'
26
26
  gem.add_dependency 'faraday'
27
27
  gem.add_dependency 'faraday_middleware'
28
+ gem.add_dependency 'multi_xml'
28
29
  end
data/lib/centro/client.rb CHANGED
@@ -29,7 +29,7 @@ module Centro
29
29
  end
30
30
  def url_from_host(host)
31
31
  (ssl_enabled? ? 'https://' : 'http://') +
32
- host
32
+ host + "/api/#{self.api_version}"
33
33
  end
34
34
  end
35
35
 
@@ -52,23 +52,22 @@ module Centro
52
52
  :client_secret => @client_secret,
53
53
  :username => username,
54
54
  :password => password)
55
- raise 'Failed to get an access token' unless response.success? && response.body['access_token']
56
- self.access_token = response.body['access_token']
55
+ self.access_token = response.body.access_token
57
56
  end
58
57
 
59
58
 
60
59
  def get_credentials
61
- auth_connection.get("/api/#{self.class.api_version}/me.json").body
60
+ auth_connection.get("me.json").body
62
61
  end
63
62
 
64
63
  def get_organizations(user_id=nil)
65
64
  options = {}
66
65
  options[:user_id]=user_id if user_id
67
- auth_connection.get("/api/#{self.class.api_version}/organizations.json", options).body
66
+ auth_connection.get("organizations.json", options).body
68
67
  end
69
68
 
70
69
  def get_members_of_organization(organization_id)
71
- auth_connection.get("/api/#{self.class.api_version}/organizations/#{organization_id}/members.json").body
70
+ auth_connection.get("organizations/#{organization_id}/members.json").body
72
71
  end
73
72
 
74
73
  ##
@@ -81,19 +80,19 @@ module Centro
81
80
  org_ids = organization_id.respond_to?(:each) ? organization_id : [organization_id]
82
81
  successfuls = []
83
82
  org_ids.each do |org_id|
84
- response = auth_connection.post("/api/#{self.class.api_version}/organizations/#{organization_id}/members.json", {:email_address => email})
83
+ response = auth_connection.post("organizations/#{organization_id}/members.json", {:email_address => email})
85
84
  response.success? && successfuls << response.body
86
85
  end
87
86
  successfuls
88
87
  end
89
88
 
90
89
  def create_user(email)
91
- response = auth_connection.post("/api/#{self.class.api_version}/members.json", {:email_address => email})
90
+ response = auth_connection.post("members.json", {:email_address => email})
92
91
  response.success? && response.body
93
92
  end
94
93
 
95
94
  def create_organization(org_name)
96
- response = auth_connection.post("/api/#{self.class.api_version}/organizations", {:name => org_name})
95
+ response = auth_connection.post("organizations", {:name => org_name})
97
96
  response.success? && response.body
98
97
  end
99
98
 
@@ -105,6 +104,7 @@ module Centro
105
104
  conn.response :dates
106
105
  conn.response :mashify
107
106
  conn.response :json, :content_type => /\bjson$/
107
+ conn.response :xml, :content_type => /\bxml$/
108
108
  conn.response :raise_error
109
109
 
110
110
  conn.adapter Faraday.default_adapter
@@ -1,5 +1,5 @@
1
1
  module Centro
2
2
  class Client
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: centro-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: multi_xml
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  description: Ruby Client for the Centro api
127
143
  email:
128
144
  - tim@galeckas.com