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

Fixing the namespacing #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "samrap/gemini",
"name": "cloudstacks/gemini",
"description": "A Gemini API client for PHP developers.",
"keywords": ["gemini", "api", "client", "cryptocurrency", "bitcoin", "ethereum"],
"license": "MIT",
Expand All @@ -11,12 +11,12 @@
],
"autoload": {
"psr-4": {
"Samrap\\Gemini\\": "src/"
"Cloudstacks\\Gemini\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Samrap\\Gemini\\Tests\\": "tests/"
"Cloudstacks\\Gemini\\Tests\\": "tests/"
},
"files": []
},
Expand Down
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ That's all you have to do to get started. The client will automatically find you

### Basic Usage

In order to talk to the API, you will need to create an instance of the `Samrap\Gemini\Gemini` class. This class implements the API contracts necessary for you to do everything the REST API has to offer.
In order to talk to the API, you will need to create an instance of the `Cloudstacks\Gemini\Gemini` class. This class implements the API contracts necessary for you to do everything the REST API has to offer.

The class takes two arguments, a `key` and `secret`, which are your API key and secret, respectively. Of course, if you only plan on using the [Public APIs](https://docs.gemini.com/rest-api/#symbols), you may ignore these arguments:

```php
use Samrap\Gemini\Gemini;
use Cloudstacks\Gemini\Gemini;

$key = 'mykey';
$secret = '1234abcd'
Expand Down Expand Up @@ -102,19 +102,19 @@ That's it! If the request was successful, the value of `$order` will be an assoc

### API Reference

The Gemini client implements two contracts, `Samrap\Gemini\PublicApi` and `Samrap\Gemini\PrivateApi`. These contracts contain the API methods and their parameters, should you need a reference.
The Gemini client implements two contracts, `Cloudstacks\Gemini\PublicApi` and `Cloudstacks\Gemini\PrivateApi`. These contracts contain the API methods and their parameters, should you need a reference.

### Error Handling

The Gemini client automatically converts all API errors into exceptions named after the **reason** in each [Error Payload](https://docs.gemini.com/rest-api/#error-payload). An `AuctionNotOpen` error will throw a `Samrap\Gemini\Exceptions\AuctionNotOpenException`, a `ClientOrderIdTooLong` will throw a `Samrap\Gemini\Exceptions\ClientOrderIdTooLongException`, etc. Every exception extends the `Samrap\Gemini\Exceptions\GeminiException`. This gives you great flexibility to handle specific errors you might expect, while adding a catch-all at the end.
The Gemini client automatically converts all API errors into exceptions named after the **reason** in each [Error Payload](https://docs.gemini.com/rest-api/#error-payload). An `AuctionNotOpen` error will throw a `Cloudstacks\Gemini\Exceptions\AuctionNotOpenException`, a `ClientOrderIdTooLong` will throw a `Samrap\Gemini\Exceptions\ClientOrderIdTooLongException`, etc. Every exception extends the `Samrap\Gemini\Exceptions\GeminiException`. This gives you great flexibility to handle specific errors you might expect, while adding a catch-all at the end.

Imagine we are writing a method to allow users to check the status of their orders. A lot can go wrong. A user might enter the incorrect order ID, so we will need to account for that. Additionally, the API might be down for maintenance and we certainly would want to log that information. Just to be safe, we should log any other error that _could_ occur. Ok, let's write it:

```php

use Samrap\Gemini\Exceptions\GeminiException;
use Samrap\Gemini\Exceptions\MaintenanceException;
use Samrap\Gemini\Exceptions\OrderNotFoundException;
use Cloudstacks\Gemini\Exceptions\GeminiException;
use Cloudstacks\Gemini\Exceptions\MaintenanceException;
use Cloudstacks\Gemini\Exceptions\OrderNotFoundException;

// ...

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/AuctionNotOpenException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class AuctionNotOpenException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ClientException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class ClientException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ClientOrderIdMustBeStringException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class ClientOrderIdMustBeStringException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ClientOrderIdTooLongException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class ClientOrderIdTooLongException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ConflictingOptionsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class ConflictingOptionsException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/EndpointMismatchException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class EndpointMismatchException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/EndpointNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class EndpointNotFoundException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/GeminiException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class GeminiException extends \Exception
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/IneligibleTimingException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class IneligibleTimingException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InsufficientFundsException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InsufficientFundsException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidJsonException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidJsonException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidNonceException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidNonceException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidOrderTypeException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidOrderTypeException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidPriceException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidPriceException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidQuantityException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidQuantityException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidSideException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidSideException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidSignatureException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidSignatureException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidSymbolException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidSymbolException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/InvalidTimestampInPayloadException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class InvalidTimestampInPayloadException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/MaintenanceException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class MaintenanceException extends GeminiException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/MissingSignatureHeaderException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Exceptions;
namespace Cloudstacks\Gemini\Exceptions;

class MissingSignatureHeaderException extends GeminiException
{
Expand Down
6 changes: 3 additions & 3 deletions src/Gemini.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini;
namespace Cloudstacks\Gemini;

use Http\Client\Exception\TransferException;
use Http\Client\HttpClient;
Expand All @@ -9,8 +9,8 @@
use Http\Message\MessageFactory;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Samrap\Gemini\Exceptions\ClientException;
use Samrap\Gemini\Exceptions\GeminiException;
use Cloudstacks\Gemini\Exceptions\ClientException;
use Cloudstacks\Gemini\Exceptions\GeminiException;

class Gemini implements PublicApi, PrivateApi
{
Expand Down
2 changes: 1 addition & 1 deletion src/Payload.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini;
namespace Cloudstacks\Gemini;

class Payload
{
Expand Down
2 changes: 1 addition & 1 deletion src/PrivateApi.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini;
namespace Cloudstacks\Gemini;

interface PrivateApi
{
Expand Down
2 changes: 1 addition & 1 deletion src/PublicApi.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini;
namespace Cloudstacks\Gemini;

interface PublicApi
{
Expand Down
2 changes: 1 addition & 1 deletion src/Signature.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini;
namespace Cloudstacks\Gemini;

class Signature
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Samrap\Gemini\Tests;
namespace Cloudstacks\Gemini\Tests;

use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\Strategy\MockClientStrategy;
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/GeminiTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Samrap\Gemini\Tests\Unit;
namespace Cloudstacks\Gemini\Tests\Unit;

use Http\Client\Exception\TransferException;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Http\Mock\Client;
use Samrap\Gemini\Gemini;
use Samrap\Gemini\Tests\TestCase;
use Cloudstacks\Gemini\Gemini;
use Cloudstacks\Gemini\Tests\TestCase;

class GeminiTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/PayloadTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Samrap\Gemini\Tests\Unit;
namespace Cloudstacks\Gemini\Tests\Unit;

use Samrap\Gemini\Payload;
use Samrap\Gemini\Tests\TestCase;
use Cloudstacks\Gemini\Payload;
use Cloudstacks\Gemini\Tests\TestCase;

class PayloadTest extends TestCase
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/SignatureTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Samrap\Gemini\Tests\Unit;
namespace Cloudstacks\Gemini\Tests\Unit;

use Samrap\Gemini\Payload;
use Samrap\Gemini\Signature;
use Samrap\Gemini\Tests\TestCase;
use Cloudstacks\Gemini\Payload;
use Cloudstacks\Gemini\Signature;
use Cloudstacks\Gemini\Tests\TestCase;

class SignatureTest extends TestCase
{
Expand Down