Class: Strobe::HTTP
- Inherits:
-
Object
- Object
- Strobe::HTTP
- Defined in:
- lib/strobe/http.rb
Instance Method Summary collapse
Instance Method Details
#deploy(deployment) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/strobe/http.rb', line 48 def deploy(deployment) connection, method = Strobe.settings.app_connection_and_method response = connection.request( :method => method, :headers => auth_header.merge(deployment.headers), :body => deployment.body.force_encoding("BINARY") ) json = JSON.parse(response.body) if error = json["error"] return nil, error else application = json["application"] errors = json["errors"] && (json["errors"]) return application, errors end end |
#login(email, pass) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/strobe/http.rb', line 30 def login(email, pass) response = http_request( "GET", Strobe.settings.url("account"), {"Content-Type" => "application/json"}.merge(auth_header(email, pass)) ) json = JSON.parse(response.body) if error = json["error"] return nil, nil, "The email and password were invalid" else user = json["user"] && User.new(json["user"]) errors = json["errors"] && (json["errors"]) return user, nil, errors end end |
#signup(email, pass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/strobe/http.rb', line 3 def signup(email, pass) body = { :account => {:name => "default"}, :user => {:email => email, :password => pass} }.to_json response = http_request( "POST", Strobe.settings.url("accounts"), {"Content-Type" => "application/json"}, body ) # user, account, error json = JSON.parse(response.body) if error = json["error"] return nil, nil, (error) else user = json["user"] && User.new(json["user"]) account = json["account"] ? Account.new(json["account"]) : true errors = json["errors"] && (json["errors"]) return user, account, errors end end |