Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

Passing Data

Jose Celano edited this page May 5, 2015 · 1 revision

In BlockCypher SDK, each object representation of JSON in Rest API, is represented as a BlockCypherModel Object. All these classes lives inside \BlockCypher\Api namespace. To send/receive any data from BlockCypher, you need to create an instance of respective BlockCypherModel, and use functions provided by the object, to make function calls like create, delete, update, execute, list, etc.

As we saw in Adding Configurations, we created an instance of WebHook and use set* methods to insert data into $webHook object. The other ways to inject similar data is as follows:

JSON String

You could directly pass the JSON string as BlockCypherModel constructor parameter, and BlockCypher SDK will fill the information accordingly. You could use get* methods to retrieve specific information about the object immediately after that. Here is the example.

$webHook = new \BlockCypher\Api\WebHook(
    '{
         "url": "https://requestb.in/slmm49sl?uniqid=554790ee32b4d",
         "event": "unconfirmed-tx"
     }'
);
// This will print the id
echo $webHook->getId();

Array Object

Similarly, array could be passed too as a constructor parameter to BlockCypherModel Object, as shown below:

$webHook = new \BlockCypher\Api\WebHook(
    array(
        "url" => "https://requestb.in/slmm49sl?uniqid=554790ee32b4d",
        "event" => "unconfirmed-tx"
    )
);
// This will print the id
echo $webHook->getId();

This ability to accept multiple data formats allow developers to create instance of BlockCypherModels with minimal interference.

Next Step