Hi,
I'm requesting an internal API with lots of different interface, each is REST :
/users/
/users/username/contacts/
/users/_username/properties/
.....
All this interfaces have a common authentication via a call to
/login
and return an auth_key that need to be used in every others calls
So I made a class for each interface, something like :
class MyApi::Users
include HTTParty
def initialize(username, password)
init = MyApi::Auth.new(username, password)
@auth_token = init.auth["id"]
end
def create(options)
end
def show(username)
end
def update(username, options)
end
def destroy(username)
end
end
So after coding all the class, my problem is if I need to call 2 different interfaces one after the other like :
def test
user = MyApi::Users.new("user", "password")
user = user.show("toto")
contacts = MyApi::Contacts.new("user", "password")
contacts = contacts.list(user.id)
end
As you see I need to authenticate twice and my instances have each a different token, do you have an idea how I could improve that without login twice. Thanks,