Giter VIP home page Giter VIP logo

rebilly-php's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rebilly-php's Issues

Add info about thread-safety to README

Hello guys!

Please, describe here and add to the README info about the thread-safety of the Rebilly\Client class. Is it depend on the value of "httpHandler" option of the class? Particularly when the Rebilly\Http\GuzzleAdapter used?

Feature Suggestion: Add "expand" Parameter to refund method

We propose adding an "expand" parameter to the refund method. This improvement, would allow users to specify additional resources to include in the response, reducing the number of requests needed to update information after a transaction refund.

Example Usage
$newTransaction = $coreService->transactions()->refund(id: 1, expand: 'invoices,parentTransaction');

Need to get the "type" of invoice

Hi there, not really an issue but if you can add the "getType()" method from the "/Entities/Invoice.php" to return the invoice "type" attribute so we can get the invoice type when querying a particular invoice. We're using it for some reporting and we'd like to have that option and doesn't break our code when updating to the new SDK in the future.

Invoice Types: Renewal, Initial, One Time, etc...

Please see attached file for the invoice types. Appreciate it!

Screen Shot 2021-07-23 at 1 48 27 PM

Create Payment fails

Creating an payment with:
client->payments()->create($paymentForm)
fails, cause the Location Header is missing in the Response. It cant be parsed.

Creating coupon fails

In entities/coupons/coupon.php function createRestriction. $data is beeing mapped there, but it contains objects, not arrays

UnprocessableEntityException is marked as deprecated

Hey guys. For now UnprocessableEntityException is marked as deprecated.
But it still used in @throws PHPDocs instead of the new DataValidationException.
Was it intentional or a mistake? Could we continue the deprecation of UnprocessableEntityException by the use of DataValidationException in PHPDocs?

Originally posted by @nevmerzhitsky in #333 (comment)

Coupon Codes not showing when the coupon has restriction of: restrict-to-products

currently using: SDK v2.12.0

PHP Fatal error: Uncaught DomainException: Unexpected type. Only discounts-per-redemption,redemptions-per-customer,restrict-to-invoices,restrict-to-plans,restrict-to-subscriptions,total-redemptions,minimum-order-amount types support in /rebilly/client-php/src/Entities/Coupons/Restriction.php:99

Solution:

  • create RestrictToProducts.php inside /rebilly/client-php/src/Entities/Coupons/Restrictions/
  • update /rebilly/client-php/src/Entities/Coupons/Restriction.php to accept type: restrict-to-products

Hoping in the next release this will be added. thanks!

Specify the Paginator template parameter to annotations of pagination methods

SDK version: 3.0.0

It will be great for introspection to have a specified template parameter of the class Paginator in all Api-class methods whose return the Paginator instance: CustomersApi::getAllPaginator(), CustomersApi::getAllEddSearchResultsPaginator() and so on like *Api::getAll*Paginator().

I mean we need just smth like this:

/**
 * @return Paginator<EddSearchResult>
 */
public function getAllEddSearchResultsPaginator(
    string $id,
    ?int $limit = null,
    ?int $offset = null,
): Paginator {
    ...
}

Do convert array of objects to array of arrays on call `jsonSerialize()`

SDK Version: 3.0.0

Some model fields are arrays of other objects. And when $model->jsonSerialize() is called, these arrays of objects aren't converted to JSON arrays, but remain objects.

Customer::jsonSerialize():

// ...
if (array_key_exists('tags', $this->fields)) {
    $data['tags'] = $this->fields['tags'];
}

ContactObject::jsonSerialize():

if (array_key_exists('phoneNumbers', $this->fields)) {
    $data['phoneNumbers'] = $this->fields['phoneNumbers'];
}
if (array_key_exists('emails', $this->fields)) {
    $data['emails'] = $this->fields['emails'];
}

Therefore a call $customer->jsonSerialize() returns (partially):

array:23 [
  "id" => "085e96b4-7f64-411b-9307-4b627f2b3007"
  "websiteId" => "example.com"
  "createdTime" => "2020-09-13T20:05:08+00:00"
  "updatedTime" => "2021-12-03T11:20:38+00:00"
  "customFields" => []
  "primaryAddress" => array:14 [
    "city" => "City 1"
    "region" => "State"
    "country" => "AF"
    "postalCode" => "111222"
    "phoneNumbers" => array:1 [
      0 => Rebilly\Sdk\Model\ContactPhoneNumbers^ {#2667
        -fields: array:3 [
          "label" => "Main"
          "value" => "+1234567890"
          "primary" => true
        ]
      }
    ]
    "emails" => array:1 [
      0 => Rebilly\Sdk\Model\ContactEmails^ {#2663
        -fields: array:3 [
          "label" => "Main"
          "value" => "[email protected]"
          "primary" => true
        ]
      }
    ]
  ]
  "tags" => array:1 [
    0 => Rebilly\Sdk\Model\Tag^ {#2658
      -fields: array:5 [
        "id" => "3759a810-f836-436c-ae8c-40f5e0ff4efe"
        "name" => "notes"
        "type" => "customer"
        "createdTime" => DateTimeImmutable @1623769937 {#2643
          date: 2021-06-15 15:12:17.0 +00:00
        }
        "updatedTime" => DateTimeImmutable @1623769937 {#2657
          date: 2021-06-15 15:12:17.0 +00:00
        }
      ]
    }
  ]

But all these objects in the subarrays must also be plain arrays.

I suggest fixing your PHP code generators to produce code like this:

$data['phoneNumbers'] = array_map(fn ($v) => $v->jsonSerialize(), $this->fields['phoneNumbers']);

Feature Suggestion: Inclusion of WebsitesApi in CoreService

Currently, WebsitesApi is absent in CoreService, whereas similar functionalities, such as PaymentInstrumentsApi, are available in both CoreService and UsersService. We propose considering the inclusion of WebsitesApi in CoreService, given that the models PaymentInstrument and Websites inherently constitute part of a shared functionality.

This update aims to better organize access to the functionality.

Issue with Rebilly\Sdk\Model\SubscriptionOrderEmbedded::setWebsite() - expects object, array given

Hello there

I'm currently work with Subscriptions, and when making a call to getAllPaginator with the 'expand' parameter set to 'website', I encounter the following error:

**Rebilly\Sdk\Model\SubscriptionOrderEmbedded::setWebsite(): Argument #1 ($website) must be of type ?object, array given, called in /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrderEmbedded.php on line 34**

Stacktrace:

[2024-02-02 10:29:47] local.ERROR: Rebilly\Sdk\Model\SubscriptionOrderEmbedded::setWebsite(): Argument #1 ($website) must be of type ?object, array given, called in /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrderEmbedded.php on line 34 {"userId":1,"exception":"[object] (TypeError(code: 0): Rebilly\\Sdk\\Model\\SubscriptionOrderEmbedded::setWebsite(): Argument #1 ($website) must be of type ?object, array given, called in /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrderEmbedded.php on line 34 at /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrderEmbedded.php:96)
[stacktrace]
#0 /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrderEmbedded.php(34): Rebilly\\Sdk\\Model\\SubscriptionOrderEmbedded->setWebsite()
#1 /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrderEmbedded.php(52): Rebilly\\Sdk\\Model\\SubscriptionOrderEmbedded->__construct()
#2 /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrder.php(730): Rebilly\\Sdk\\Model\\SubscriptionOrderEmbedded::from()
#3 /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrder.php(240): Rebilly\\Sdk\\Model\\SubscriptionOrder->setEmbedded()
#4 /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionOrder.php(246): Rebilly\\Sdk\\Model\\SubscriptionOrder->__construct()
#5 /www/backend/vendor/rebilly/client-php/src/Model/SubscriptionFactory.php(24): Rebilly\\Sdk\\Model\\SubscriptionOrder::from()
#6 /www/backend/vendor/rebilly/client-php/src/Api/SubscriptionsApi.php(193): Rebilly\\Sdk\\Model\\SubscriptionFactory::from()
#7 [internal function]: Rebilly\\Sdk\\Api\\SubscriptionsApi->Rebilly\\Sdk\\Api\\{closure}()
#8 /www/backend/vendor/rebilly/client-php/src/Api/SubscriptionsApi.php(193): array_map()
#9 /www/backend/vendor/rebilly/client-php/src/Api/SubscriptionsApi.php(208): Rebilly\\Sdk\\Api\\SubscriptionsApi->getAll()
#10 /www/backend/vendor/rebilly/client-php/src/Paginator.php(122): Rebilly\\Sdk\\Api\\SubscriptionsApi->Rebilly\\Sdk\\Api\\{closure}()
#11 /www/backend/vendor/rebilly/client-php/src/Paginator.php(59): Rebilly\\Sdk\\Paginator->load()
#12 /www/backend/app/Repositories/SubscriptionRepository.php(77): Rebilly\\Sdk\\Paginator->current()
#13 /www/backend/app/Http/Controllers/CustomerController.php(55): App\\Repositories\\SubscriptionRepository->findByCustomerId()

Snippet:

$subscriptionsPaginator = $this->coreService->subscriptions()->getAllPaginator(
            filter: Rebilly::buildFilterString(['customerId' => $ids]),
            expand: 'website'
        );

It seems that the SDK is unable to parse the object as expected. The issue might be related to the structure of the returned data. Could you please investigate this issue and provide guidance on how to resolve it?

This issue is not limited to the Subscription model; similar problems are observed with other models like Transactions.

SDK Version: 3.0.0
ENV: PHP 8.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.