Class: Users_api
Class Method Summary collapse
- .auth_user(api_key, body, opts = {}) ⇒ Object
- .create_card_for_user(user_id, api_key, body, opts = {}) ⇒ Object
- .create_user(api_key, body, opts = {}) ⇒ Object
- .delete_user(user_id, api_key, opts = {}) ⇒ Object
- .delete_user_credit_card(user_id, card_id, api_key, opts = {}) ⇒ Object
-
.escapeString(string) ⇒ Object
apiInvoker = APIInvoker.
- .get_user(user_id, api_key, use_cache, opts = {}) ⇒ Object
- .get_users_cards(user_id, api_key, opts = {}) ⇒ Object
- .search_users_by_name(user_name, api_key, use_cache, opts = {}) ⇒ Object
Class Method Details
.auth_user(api_key, body, opts = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/users_api.rb', line 102 def self.auth_user (api_key,body,opts={}) query_param_keys = [:api_key] # verify existence of params raise "api_key is required" if api_key.nil? raise "body is required" if body.nil? # set default values and merge with input = { :api_key => api_key, :body => body}.merge(opts) #resource path path = "/users/authenticate".sub('{format}','json') # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil if body != nil if body.is_a?(Array) array = Array.new body.each do |item| if item.respond_to?("to_body".to_sym) array.push item.to_body else array.push item end end post_body = array else if body.respond_to?("to_body".to_sym) post_body = body.to_body else post_body = body end end end response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body AuthResponse.new(response) end |
.create_card_for_user(user_id, api_key, body, opts = {}) ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/users_api.rb', line 193 def self.create_card_for_user (user_id,api_key,body,opts={}) query_param_keys = [:api_key] # verify existence of params raise "user_id is required" if user_id.nil? raise "api_key is required" if api_key.nil? raise "body is required" if body.nil? # set default values and merge with input = { :user_id => user_id, :api_key => api_key, :body => body}.merge(opts) #resource path path = "/users/{user_id}/cards".sub('{format}','json').sub('{' + 'user_id' + '}', escapeString(user_id)) # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil if body != nil if body.is_a?(Array) array = Array.new body.each do |item| if item.respond_to?("to_body".to_sym) array.push item.to_body else array.push item end end post_body = array else if body.respond_to?("to_body".to_sym) post_body = body.to_body else post_body = body end end end response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body CardStatus.new(response) end |
.create_user(api_key, body, opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/users_api.rb', line 11 def self.create_user (api_key,body,opts={}) query_param_keys = [:api_key] # verify existence of params raise "api_key is required" if api_key.nil? raise "body is required" if body.nil? # set default values and merge with input = { :api_key => api_key, :body => body}.merge(opts) #resource path path = "/users".sub('{format}','json') # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil if body != nil if body.is_a?(Array) array = Array.new body.each do |item| if item.respond_to?("to_body".to_sym) array.push item.to_body else array.push item end end post_body = array else if body.respond_to?("to_body".to_sym) post_body = body.to_body else post_body = body end end end response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body NewUser.new(response) end |
.delete_user(user_id, api_key, opts = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/users_api.rb', line 78 def self.delete_user (user_id,api_key,opts={}) query_param_keys = [:api_key] # verify existence of params raise "user_id is required" if user_id.nil? raise "api_key is required" if api_key.nil? # set default values and merge with input = { :user_id => user_id, :api_key => api_key}.merge(opts) #resource path path = "/users/{user_id}".sub('{format}','json').sub('{' + 'user_id' + '}', escapeString(user_id)) # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil response = Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body DeleteUserStatus.new(response) end |
.delete_user_credit_card(user_id, card_id, api_key, opts = {}) ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/users_api.rb', line 238 def self.delete_user_credit_card (user_id,card_id,api_key,opts={}) query_param_keys = [:api_key] # verify existence of params raise "user_id is required" if user_id.nil? raise "card_id is required" if card_id.nil? raise "api_key is required" if api_key.nil? # set default values and merge with input = { :user_id => user_id, :card_id => card_id, :api_key => api_key}.merge(opts) #resource path path = "/users/{user_id}/cards/{card_id}".sub('{format}','json').sub('{' + 'user_id' + '}', escapeString(user_id)) .sub('{' + 'card_id' + '}', escapeString(card_id)) # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil response = Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body Status.new(response) end |
.escapeString(string) ⇒ Object
apiInvoker = APIInvoker
7 8 9 |
# File 'lib/users_api.rb', line 7 def self.escapeString(string) URI.encode(string.to_s) end |
.get_user(user_id, api_key, use_cache, opts = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/users_api.rb', line 54 def self.get_user (user_id,api_key,use_cache,opts={}) query_param_keys = [:api_key,:use_cache] # verify existence of params raise "user_id is required" if user_id.nil? raise "api_key is required" if api_key.nil? # set default values and merge with input = { :user_id => user_id, :api_key => api_key, :use_cache => use_cache}.merge(opts) #resource path path = "/users/{user_id}".sub('{format}','json').sub('{' + 'user_id' + '}', escapeString(user_id)) # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body User.new(response) end |
.get_users_cards(user_id, api_key, opts = {}) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/users_api.rb', line 169 def self.get_users_cards (user_id,api_key,opts={}) query_param_keys = [:api_key] # verify existence of params raise "user_id is required" if user_id.nil? raise "api_key is required" if api_key.nil? # set default values and merge with input = { :user_id => user_id, :api_key => api_key}.merge(opts) #resource path path = "/users/{user_id}/cards".sub('{format}','json').sub('{' + 'user_id' + '}', escapeString(user_id)) # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body response.map {|response|Card.new(response)} end |
.search_users_by_name(user_name, api_key, use_cache, opts = {}) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/users_api.rb', line 145 def self.search_users_by_name (user_name,api_key,use_cache,opts={}) query_param_keys = [:api_key,:use_cache] # verify existence of params raise "user_name is required" if user_name.nil? raise "api_key is required" if api_key.nil? # set default values and merge with input = { :user_name => user_name, :api_key => api_key, :use_cache => use_cache}.merge(opts) #resource path path = "/users/search/name/{user_name}".sub('{format}','json').sub('{' + 'user_name' + '}', escapeString(user_name)) # pull querystring keys from options queryopts = .select do |key,value| query_param_keys.include? key end headers = nil post_body = nil response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body User.new(response) end |