BlockIo / block_io-php

PHP library for Block.io
MIT License
56 stars 139 forks source link

Create user "label" is different from "user_id": BlockIo documentation confusion #2

Closed tim-peterson closed 10 years ago

tim-peterson commented 10 years ago

The documentation isn't ideal for the create_user API method:

https://block.io/api/simple/php

When you call this method, $response=$block_io->create_user(array('label' => 'some value'));, you can also call this $response=$block_io->create_user(array('user_id' => 'some value'));

The latter's $response gives you both a user_id and a label. However, only the user_id returned by BlockIo can be used in the get_user_balance method

$block_io->get_user_balance(array('user_id' => 'USER ID'));

It would be preferable to clarify in this PHP library and on the BlockIo's site documentation that the label is something the developer defines whereas user_id is set by BlockIo.

doersf commented 10 years ago

Hey Tim, user_id was indeed user-definable on DogeAPI. However, Block.io has fixed user_ids that it assigned, and they are always integers. The only way you can 'mark' an address is by defining a custom label for it.

Take for example the case of creating a user to collect payment on an invoice. In this case, you can create_user with a random label, or you can create_user with label='userXinvoice1'. The latter is the preferred approach.

Keep in mind that get_new_address has the same behavior; the calls are basically aliases to let our users know they can cater to creating users as well, which in some cases is not obvious to them at all.

tim-peterson commented 10 years ago

Thanks @doersf. My only question is that user_id and not label is required for the get_user_balance and withdraw_from_user methods.

This means we developers will need to keep track of both the user_id and label. This should be made more clear to everyone in the documentation.

doersf commented 10 years ago

Ah, I understand. I'll add this to the TODO list; you really shouldn't have to track labels and user IDs.

tim-peterson commented 10 years ago

Thanks that'd be great. If we could use label for get_user_balance, withdraw_from_user, etc. that would be awesome!

tim-peterson commented 10 years ago

@doersf any updates on a fix for not making us track labels and user IDs?

doersf commented 10 years ago

Hey Tim, it's bunched in with some updates we're currently testing for rapid withdrawals. Will let you know once we push these live with relevant doc updates. Cheers :)

tim-peterson commented 10 years ago

Sounds good thanks!

doersf commented 10 years ago

Tim, new methods are now available:

withdraw_from_users, withdraw_from_addresses, withdraw_from_labels

Check them out: https://block.io/api#withdrawal-methods

PHP library was also updated to include these. Cheers!

tim-peterson commented 10 years ago

I see them in the PHP library that I just updated with Composer! awesome!

It would be good to add to the docs for create_user and Withdraw From Labels, that the labels, like the user_id, must be unique such that one can't send/receive from multiple users using the withdrawal_from_labels method.

doersf commented 10 years ago

Good point, will make it clear. Cheers, Tim.