Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account object creates an un-necessary request #3

Open
marcrohloff opened this issue Jan 3, 2017 · 2 comments
Open

Account object creates an un-necessary request #3

marcrohloff opened this issue Jan 3, 2017 · 2 comments

Comments

@marcrohloff
Copy link
Contributor

In the code example:

    account = Weeblycloud::Account.new
    user = account.create_user("[email protected]")
    site = user.create_site("domain.com", "site_title" => "My Website")
    puts site.login_link()

4 http requests are made (one for each line), even though only 3 are necessary. (There is no need to fetch the account object). I just submitted a PR which allows data to be passed into the account so at least you can do:

    account = Weeblycloud::Account.new({})

but this is not ideal.

The same is true of other objects. For example (assuming a already know the user and site id) I shouldn't have to fetch the site object to retrieve the login_link

@puddi
Copy link
Contributor

puddi commented Mar 8, 2017

While unideal, you can use the same workaround for passing {} into the Site class when constructing it. I'm not sure there's a nice compromise between fetching Site-object data and fetching other endpoint data for the Site APIs.

@marcrohloff
Copy link
Contributor Author

To me an ideal solution would be to make the initializer more specific:
Account.new(load:true), Account.new(load:false) or Account.new(data: {....}) with the first being the default.

A simpler alternative would be to allow an initializer of the form Account.new(false) which would be a small modification to CloudResource#initialize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants