Class: BillingSystem::Remote::Client
- Inherits:
-
Object
- Object
- BillingSystem::Remote::Client
- Defined in:
- lib/billingsystem-remote-client.rb
Class Method Summary collapse
-
.build_user(options = {}) ⇒ Object
Build a user but don’t save it.
-
.create_user(options = {}) ⇒ Object
Create a user remotely.
-
.set_credentials(options = {}) ⇒ Object
Sets credentials for communicating with the API.
-
.set_endpoint(str) ⇒ Object
Sets the endpoint for communicating with the API.
Class Method Details
.build_user(options = {}) ⇒ Object
Build a user but don’t save it.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/billingsystem-remote-client.rb', line 38 def self.build_user( = {}) OptionsChecker.check(, [ :email, :password, :password_confirmation ]) email = [:email] password = [:password] password_confirmation = [:password_confirmation] # +_+ # @user = Frontend::User.new( :email => email, :password => password, :password_confirmation => password_confirmation ) # return it! @user end |
.create_user(options = {}) ⇒ Object
Create a user remotely. Will immediately save the user and return true/false depending on success.
50 51 52 53 54 55 56 |
# File 'lib/billingsystem-remote-client.rb', line 50 def self.create_user( = {}) @user = build_user() # return it! ret = @user.save ret end |
.set_credentials(options = {}) ⇒ Object
Sets credentials for communicating with the API. Used for HTTP Basic auth.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/billingsystem-remote-client.rb', line 25 def self.set_credentials( = {}) # BillingSystem::Remote::Client.set_credentials( :username => "1abc927b5b4f35f517983599ccc86c64", :password => "e9510b9e7c47275376d1efd4fd75f680" ) OptionsChecker.check(, [ :username, :password ]) # +_+ # username = [:username] password = [:password] # +_+ # # Set it! Frontend::User.user = username Frontend::User.password = password end |
.set_endpoint(str) ⇒ Object
Sets the endpoint for communicating with the API. Please note that the gem will talk to the UsersController, so if you provide an endpoint my-app.apphoster.com/frontend/, we will actually start talking to my-app.apphoster.com/frontend/users This is because we believe in Resource-Oriented (Restful) routes! :))))
20 21 22 |
# File 'lib/billingsystem-remote-client.rb', line 20 def self.set_endpoint(str) Frontend::User.site = str end |