Skip to content

Commit

Permalink
Merge pull request #11 from levanto-financial/user-register
Browse files Browse the repository at this point in the history
User registeration and de-registration
  • Loading branch information
mike-north committed Mar 8, 2016
2 parents a89fd0a + 6fc98c3 commit eb559e3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,48 @@ end

```

Or you could create and then immediately delete a user

```ex

case Yodlee.as_cob(
System.get_env("COBRAND_USERNAME"),
System.get_env("COBRAND_PASSWORD"), fn cob_tok ->

IO.puts "======== CREATE A USER ========"

{:ok, new_user} = Yodlee.User.create cob_tok, %{
"user" => %{
"loginName" => "mike-logina",
"password" => "aho12eoed12d$$Aa",
"email" => "[email protected]"}}



IO.puts "======== AND DELETE IT ========"

user_tok = new_user["user"]["session"]["userSession"]
Yodlee.User.delete cob_tok, user_tok

new_user
end) do
{:ok, result} ->
IO.inspect result
{:error, err} -> raise err
end

```

## API Coverage

- [x] **get** - /{cobrandName}/v1/cobrand/publicKey
- [x] **post** - /{cobrandName}/v1/cobrand/logout
- [x] **post** - /{cobrandName}/v1/cobrand/login
- [ ] **post** - /{cobrandName}/v1/user/register
- [x] **post** - /{cobrandName}/v1/user/register
- [ ] **get** - /{cobrandName}/v1/user
- [ ] **get** - /{cobrandName}/v1/user/credentials/token
- [ ] **post** - /{cobrandName}/v1/user/credentials
- [ ] **delete** - /{cobrandName}/v1/user/unregister
- [x] **delete** - /{cobrandName}/v1/user/unregister
- [ ] **post** - /{cobrandName}/v1/user/samlRegister
- [ ] **post** - /{cobrandName}/v1/user/samlLogin
- [x] **post** - /{cobrandName}/v1/user/logout
Expand Down
26 changes: 26 additions & 0 deletions lib/yodlee/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,30 @@ defmodule Yodlee.User do
{:ok, res} = login(cob_session_token, user_login, user_password, cobrand_name)
res
end

# Returns:
# {
# "user": {
# "id": 25890176,
# "loginName": "levanto-12312a",
# "name": {},
# "session": {
# "userSession": "06102015_0:d8744eff21d68ab60497ae1bbcfd5c7a59a69e75ac4625c8d3b8ccd4639ee6ee5c6a8df0dde8f91c9c03d48fe4b5e748f440bd521741f8958df07599f5b805e5"
# },
# "preferences": {
# "currency": "USD",
# "timeZone": "PST",
# "dateFormat": "MM/dd/yyyy"
# }
# }
# }
def create(cob_session_token, params, cobrand_name \\ Yodlee.default_cobrand_name) do
Yodlee.make_authenticated_request(cob_session_token, "post", "#{cobrand_name}/v1/user/register", %{
"registerParam" => Poison.encode!(params)
})
end

def delete(cob_session_token, user_session_token, cobrand_name \\ Yodlee.default_cobrand_name) do
Yodlee.make_authenticated_request({cob_session_token, user_session_token}, "delete", "#{cobrand_name}/v1/user/unregister")
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Yodlee.Mixfile do

def project do
[app: :yodlee,
version: "0.1.1",
version: "0.1.2",
elixir: "~> 1.1",
description: "Yodlee API",
package: package,
Expand Down
2 changes: 1 addition & 1 deletion test/auth_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule YodleeAuthTest do
doctest Yodlee.Cobrand

test "successful cobrand login" do
Yodlee.MockHandler.add_mock_response "post", "restserver/v1/cobrand/login", fn _ ->
Yodlee.MockHandler.add_mock_response "post", "#{Yodlee.default_cobrand_name}/v1/cobrand/login", fn _ ->
{:ok, %{
"applicationId" => "3A4CAE9B71A1CCD7FF41F51006E9ED00",
"cobrandId" => 1111,
Expand Down

0 comments on commit eb559e3

Please sign in to comment.