Skip to content

Instantly share code, notes, and snippets.

Avatar

David Azevedo davixz

View GitHub Profile
View gist:5046918350800e220154e9718e6a11b1
You can use throw new Error() normally
throw new Error('My error message');
You can give a id to the error like so
let error = new Error('My error message');
error.name = 'my_error_id';
throw error;
View gist:3843c1b51c52f1c03946e846b563af00
Error Handling
The pattern of error return is:
{
status: 500,
errors: [
{ message: '......' }, //message will always be present
{ message: '......', id: '...' } //id may not always be present so check the existence before usage
{ message: '......', id: '...', stack_trace: '' } //its used for exception stack trace on dev
View gist:5d057e712de1d288d175c0b43bb858eb
public function cardLinkHolder($userWalletCard, $user, $token) {
$toolsSvc = $this->sc->get('tools');
$userWalletCardSvc = $this->sc->get('rp_user_wallet_card');
$userBirthdate = $user->getBirthdate();
$userGender = $user->getGender();
if($userGender) {
if($userGender == "M") {
$userGender = "male";
} else if($userGender == "F") {
View gist:befcf78825fea92c5000dbb65e86ae3c
{
"error": {
"message": "aaaa is not defined",
"name": "ReferenceError",
"frames": [
{
"file": "src/app/strategies/provider/loggi/loggi-strategy.js",
"filePath": "/var/www/newtail/newtail-logistic-hub/src/app/strategies/provider/loggi/loggi-strategy.js",
"method": "LoggiStrategy.deliveryOrderCreate",
"line": 167,
View gist:a450a77c7d8c2ff175c0797879ae12de
mutation CreateOrder(
$externalId: String!,
$trackingKey: String!
$pickups: [Pickup]!,
$packages: [Packages]!
$paymentMethod: Int!
) {
createOrder(input: {
externalId: $externalId
trackingKey: $trackingKey
View gist:95921de1336e67bcba3eaad883b3236d
Request {
"url": "https://staging.loggi.com/graphql/?",
"method": "post",
"data": {
"query": "\n mutation CreateOrder(\n $externalId: String!, \n $trackingKey: String!\n $pickups: [Pickup]!, \n $packages: [Packages]!\n $paymentMethod: Int!\n ) {\n createOrder(input: {\n externalId: $externalId\n trackingKey: $trackingKey\n pickups: $pickups\n packages: $packages\n paymentMethod: $paymentMethod\n }) {\n success\n shop {\n pk\n name\n }\n orders {\n pk\n trackingKey\n packages {\n pk\n status\n pickupWaypoint {\n index\n indexDisplay\n eta\n legDistance\n }\n waypoint {\n index\n indexDispla
View gist:cf8d3d6f8a1013e4c99e9bc0553c1b53
Request {
"url": "/?",
"method": "post",
"data": {
"query": "\n mutation CreateOrder(\n $externalId: String!, \n $trackingKey: String!\n $pickups: [Pickup]!, \n $packages: [Packages]!\n $paymentMethod: Int!\n ) {\n createOrder(input: {\n externalId: $externalId\n trackingKey: $trackingKey\n pickups: $pickups\n packages: $packages\n paymentMethod: $paymentMethod\n }) {\n success\n shop {\n pk\n name\n }\n orders {\n pk\n trackingKey\n packages {\n pk\n status\n pickupWaypoint {\n index\n indexDisplay\n eta\n legDistance\n }\n waypoint {\n index\n indexDisplay\n eta\n
View gist:30a7fd9014b39010efbc31457dd3c74e
{
"data": {
"estimateCreateOrder": {
"totalEstimate": {
"totalCost": "81.04",
"totalEta": 2552,
"totalDistance": 50.18
},
"ordersEstimate": [
{
View gist:8b73c7bdc250f00e348aac9c64e2fb4c
Passo 01 chamar /location/configGet
Para ver se uma location nossa ja esta registrada
{
"location_id": "3",
"provider": "loggi"
}
Passo 02 chamar /location/config (se necessario)
View gist:387e057a635ee0396323c7e669f514ce
{
"data": {
"estimateCreateOrder": {
"totalEstimate": {
"totalCost": "81.04",
"totalEta": 2552,
"totalDistance": 50.18
},
"ordersEstimate": [
{