Skip to content

Commit

Permalink
Fixed modelClass property
Browse files Browse the repository at this point in the history
  • Loading branch information
kg-bot committed Sep 30, 2020
1 parent 0889e72 commit bf235ec
Show file tree
Hide file tree
Showing 31 changed files with 192 additions and 173 deletions.
18 changes: 9 additions & 9 deletions src/Models/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
class Customer extends Model
{

protected $entity = 'customers';
protected $primaryKey = 'number';
protected $entity = 'customers';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function contacts()
{
return $this->request->handleWithExceptions(function () {
public function contacts() {
return $this->request->handleWithExceptions( function () {

$builder = new CustomerContactBuilder($this->request, $this->url_friendly_id);
$builder = new CustomerContactBuilder( $this->request, $this->url_friendly_id );

return $builder->get();
});
}
return $builder->get();
} );
}
}
5 changes: 3 additions & 2 deletions src/Models/CustomerContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class CustomerContact extends Model
{

protected $entity = 'customers/{customer}/contacts';
protected $primaryKey = 'number';
protected $entity = 'customers/{customer}/contacts';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
5 changes: 3 additions & 2 deletions src/Models/CustomerGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class CustomerGroup extends Model
{
protected $entity = 'customer-groups';
protected $primaryKey = 'number';
protected $entity = 'customer-groups';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
25 changes: 13 additions & 12 deletions src/Models/CustomerInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
class CustomerInvoice extends Model
{

protected $entity = 'customer-invoices';
protected $primaryKey = 'number';

/**
* Book customer invoice
*
* @param bool|array $send_email [optional] <p>
* This parameter indicates should the mail be sent to customer,
* if you send it as array it must be in format like this:
* [
* "send" => false,
* "body" => "Something",
protected $entity = 'customer-invoices';
protected $primaryKey = 'number';
protected $modelClass = self::class;

/**
* Book customer invoice
*
* @param bool|array $send_email [optional] <p>
* This parameter indicates should the mail be sent to customer,
* if you send it as array it must be in format like this:
* [
* "send" => false,
* "body" => "Something",
* "subject" => "YOUR SUBJECT",
* "receivers" => [
* "to" => [ "email@here.com"],
Expand Down
1 change: 1 addition & 0 deletions src/Models/DeliveryTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class DeliveryTerm extends Model
{
protected $entity = 'delivery-terms';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
1 change: 1 addition & 0 deletions src/Models/DraftOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DraftOrder extends Model
{
protected $entity = 'orders/drafts';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function getPDF() {
return $this->request->handleWithExceptions( function () {
Expand Down
18 changes: 9 additions & 9 deletions src/Models/DraftPurchaseOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

class DraftPurchaseOrder extends Model
{
protected $entity = 'purchase-orders/drafts';
protected $primaryKey = 'number';
protected $entity = 'purchase-orders/drafts';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function getPDF()
{
return $this->request->handleWithExceptions( function () {
$response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf");
public function getPDF() {
return $this->request->handleWithExceptions( function () {
$response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" );


return json_decode((string)$response->getBody());
} );
}
return json_decode( (string) $response->getBody() );
} );
}
}
5 changes: 3 additions & 2 deletions src/Models/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class Employee extends Model
{

protected $entity = 'employees';
protected $primaryKey = 'number';
protected $entity = 'employees';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
7 changes: 4 additions & 3 deletions src/Models/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

class Field extends Model
{
public $number;
protected $entity = 'fields';
protected $primaryKey = 'slug';
public $number;
protected $entity = 'fields';
protected $primaryKey = 'slug';
protected $modelClass = self::class;
}
5 changes: 3 additions & 2 deletions src/Models/InventoryAdjustment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class InventoryAdjustment extends Model
{
protected $entity = 'inventory-adjustments';
protected $primaryKey = 'id';
protected $entity = 'inventory-adjustments';
protected $primaryKey = 'id';
protected $modelClass = self::class;
}
5 changes: 3 additions & 2 deletions src/Models/InventoryMovement.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class InventoryMovement extends Model
{
protected $entity = 'inventory-movements';
protected $primaryKey = 'id';
protected $entity = 'inventory-movements';
protected $primaryKey = 'id';
protected $modelClass = self::class;
}
5 changes: 3 additions & 2 deletions src/Models/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class Layout extends Model
{
protected $entity = 'layouts';
protected $primaryKey = 'number';
protected $entity = 'layouts';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
17 changes: 9 additions & 8 deletions src/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

class Location extends Model
{
protected $entity = 'locations';
protected $primaryKey = 'number';
protected $fillable = [
protected $entity = 'locations';
protected $primaryKey = 'number';
protected $modelClass = self::class;
protected $fillable = [

"name",
"is_default",
"number",
"parent_id",
];
"name",
"is_default",
"number",
"parent_id",
];
}
18 changes: 9 additions & 9 deletions src/Models/Lot.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@

class Lot extends Model
{
public $number;
protected $entity = 'lots';
protected $primaryKey = 'number';
public $number;
protected $entity = 'lots';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function variations( $variation_id = 1001 )
{
return $this->request->handleWithExceptions( function () use ( $variation_id ) {
public function variations( $variation_id = 1001 ) {
return $this->request->handleWithExceptions( function () use ( $variation_id ) {

$response = $this->request->client->get("variations/{$this->url_friendly_id}/variation-matrix");
$response = $this->request->client->get( "variations/{$this->url_friendly_id}/variation-matrix" );


return json_decode((string)$response->getBody());
} );
return json_decode( (string) $response->getBody() );
} );
}

public function location()
Expand Down
18 changes: 9 additions & 9 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

class Order extends Model
{
protected $entity = 'orders';
protected $primaryKey = 'number';
protected $entity = 'orders';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function getPDF()
{
return $this->request->handleWithExceptions( function () {
$response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf");
public function getPDF() {
return $this->request->handleWithExceptions( function () {
$response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" );


return json_decode((string)$response->getBody());
} );
}
return json_decode( (string) $response->getBody() );
} );
}

public function reopen()
{
Expand Down
5 changes: 3 additions & 2 deletions src/Models/OrderNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class OrderNote extends Model
{
protected $entity = 'orders/:number/notes';
protected $primaryKey = 'id';
protected $entity = 'orders/:number/notes';
protected $primaryKey = 'id';
protected $modelClass = self::class;

}
26 changes: 14 additions & 12 deletions src/Models/OrderShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@

class OrderShipment extends Model
{
protected $entity = 'order-shipments';
protected $primaryKey = 'id';

/**
* Mark shipment as shipped
*
* @param bool $pick Mark all shipment lines as picked
* @return mixed
* @throws \Rackbeat\Exceptions\RackbeatClientException
* @throws \Rackbeat\Exceptions\RackbeatRequestException
*/
public function markShipped($pick = true)
protected $entity = 'order-shipments';
protected $primaryKey = 'id';
protected $modelClass = self::class;

/**
* Mark shipment as shipped
*
* @param bool $pick Mark all shipment lines as picked
*
* @return mixed
* @throws \Rackbeat\Exceptions\RackbeatClientException
* @throws \Rackbeat\Exceptions\RackbeatRequestException
*/
public function markShipped( $pick = true )
{
return $this->request->handleWithExceptions(function () use ($pick) {

Expand Down
5 changes: 3 additions & 2 deletions src/Models/PaymentTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class PaymentTerm extends Model
{
protected $entity = 'payment-terms';
protected $primaryKey = 'number';
protected $entity = 'payment-terms';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
19 changes: 9 additions & 10 deletions src/Models/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
class Plugin extends Model
{

protected $entity = 'user-account-plugins';
protected $primaryKey = 'id';
protected $entity = 'user-account-plugins';
protected $primaryKey = 'id';
protected $modelClass = self::class;

public function delete()
{
throw new MethodNotImplemented();
}
public function delete() {
throw new MethodNotImplemented();
}

public function update( $data = [] )
{
throw new MethodNotImplemented();
}
public function update( $data = [] ) {
throw new MethodNotImplemented();
}
}
3 changes: 2 additions & 1 deletion src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ class Product extends Model
public $number;
protected $entity = 'products';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function inventoryMatrix( $location_id = null, array $filter = null ) {
return $this->request->handleWithExceptions( function () use ( $location_id, $filter ) {

$query = '';

// We need to use location filter if user has provided any
if ( !is_null( $location_id ) ) {
if ( ! is_null( $location_id ) ) {

$query .= '?location_id=' . $location_id;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Models/ProductGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

class ProductGroup extends Model
{
public $number;
protected $entity = 'product-groups';
protected $primaryKey = 'number';
public $number;
protected $entity = 'product-groups';
protected $primaryKey = 'number';
protected $modelClass = self::class;
}
18 changes: 9 additions & 9 deletions src/Models/ProductionOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

class ProductionOrder extends Model
{
protected $entity = 'production-orders';
protected $primaryKey = 'number';
protected $entity = 'production-orders';
protected $primaryKey = 'number';
protected $modelClass = self::class;

public function getPDF()
{
return $this->request->handleWithExceptions( function () {
$response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf");
public function getPDF() {
return $this->request->handleWithExceptions( function () {
$response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" );


return json_decode((string)$response->getBody());
} );
}
return json_decode( (string) $response->getBody() );
} );
}
}
Loading

0 comments on commit bf235ec

Please sign in to comment.