Coupon extends RecurlyResource
Table of Contents
- $array_hints : mixed
- $_applies_to_all_items : mixed
- $_applies_to_all_plans : mixed
- $_applies_to_non_plan_charges : mixed
- $_code : mixed
- $_coupon_type : mixed
- $_created_at : mixed
- $_discount : mixed
- $_duration : mixed
- $_expired_at : mixed
- $_free_trial_amount : mixed
- $_free_trial_unit : mixed
- $_hosted_page_description : mixed
- $_id : mixed
- $_invoice_description : mixed
- $_items : mixed
- $_max_redemptions : mixed
- $_max_redemptions_per_account : mixed
- $_name : mixed
- $_object : mixed
- $_plans : mixed
- $_redeem_by : mixed
- $_redemption_resource : mixed
- $_response : mixed
- $_state : mixed
- $_temporal_amount : mixed
- $_temporal_unit : mixed
- $_unique_code_template : mixed
- $_unique_coupon_code : mixed
- $_unique_coupon_codes_count : mixed
- $_updated_at : mixed
- __construct() : mixed
- Constructor
- __debugInfo() : array<string|int, mixed>
- Override of the magic method __debugInfo that will only return the relevant attributes of the \Recurly\RecurlyResource
- __set() : void
- Guard against setting invalid properties
- cast() : RecurlyResource
- Recursively converts a response object into a \Recurly\RecurlyResource.
- fromBinary() : BinaryFile
- Converts a binary response into a Recurly BinaryFile
- fromEmpty() : EmptyResource
- Returns a \Recurly\EmptyResource for API requests that do not have a response body.
- fromResponse() : RecurlyResource
- Converts a Recurly response object into a \Recurly\RecurlyResource.
- getAppliesToAllItems() : bool|null
- Getter method for the applies_to_all_items attribute.
- getAppliesToAllPlans() : bool|null
- Getter method for the applies_to_all_plans attribute.
- getAppliesToNonPlanCharges() : bool|null
- Getter method for the applies_to_non_plan_charges attribute.
- getCode() : string|null
- Getter method for the code attribute.
- getCouponType() : string|null
- Getter method for the coupon_type attribute.
- getCreatedAt() : string|null
- Getter method for the created_at attribute.
- getDiscount() : CouponDiscount|null
- Getter method for the discount attribute.
- getDuration() : string|null
- Getter method for the duration attribute.
- getExpiredAt() : string|null
- Getter method for the expired_at attribute.
- getFreeTrialAmount() : int|null
- Getter method for the free_trial_amount attribute.
- getFreeTrialUnit() : string|null
- Getter method for the free_trial_unit attribute.
- getHostedPageDescription() : string|null
- Getter method for the hosted_page_description attribute.
- getId() : string|null
- Getter method for the id attribute.
- getInvoiceDescription() : string|null
- Getter method for the invoice_description attribute.
- getItems() : array<string|int, mixed>
- Getter method for the items attribute.
- getMaxRedemptions() : int|null
- Getter method for the max_redemptions attribute.
- getMaxRedemptionsPerAccount() : int|null
- Getter method for the max_redemptions_per_account attribute.
- getName() : string|null
- Getter method for the name attribute.
- getObject() : string|null
- Getter method for the object attribute.
- getPlans() : array<string|int, mixed>
- Getter method for the plans attribute.
- getRedeemBy() : string|null
- Getter method for the redeem_by attribute.
- getRedemptionResource() : string|null
- Getter method for the redemption_resource attribute.
- getResponse() : Response
- Getter for the Recurly HTTP Response
- getState() : string|null
- Getter method for the state attribute.
- getTemporalAmount() : int|null
- Getter method for the temporal_amount attribute.
- getTemporalUnit() : string|null
- Getter method for the temporal_unit attribute.
- getUniqueCodeTemplate() : string|null
- Getter method for the unique_code_template attribute.
- getUniqueCouponCode() : object|null
- Getter method for the unique_coupon_code attribute.
- getUniqueCouponCodesCount() : int|null
- Getter method for the unique_coupon_codes_count attribute.
- getUpdatedAt() : string|null
- Getter method for the updated_at attribute.
- setAppliesToAllItems() : void
- Setter method for the applies_to_all_items attribute.
- setAppliesToAllPlans() : void
- Setter method for the applies_to_all_plans attribute.
- setAppliesToNonPlanCharges() : void
- Setter method for the applies_to_non_plan_charges attribute.
- setCode() : void
- Setter method for the code attribute.
- setCouponType() : void
- Setter method for the coupon_type attribute.
- setCreatedAt() : void
- Setter method for the created_at attribute.
- setDiscount() : void
- Setter method for the discount attribute.
- setDuration() : void
- Setter method for the duration attribute.
- setExpiredAt() : void
- Setter method for the expired_at attribute.
- setFreeTrialAmount() : void
- Setter method for the free_trial_amount attribute.
- setFreeTrialUnit() : void
- Setter method for the free_trial_unit attribute.
- setHostedPageDescription() : void
- Setter method for the hosted_page_description attribute.
- setId() : void
- Setter method for the id attribute.
- setInvoiceDescription() : void
- Setter method for the invoice_description attribute.
- setItems() : void
- Setter method for the items attribute.
- setMaxRedemptions() : void
- Setter method for the max_redemptions attribute.
- setMaxRedemptionsPerAccount() : void
- Setter method for the max_redemptions_per_account attribute.
- setName() : void
- Setter method for the name attribute.
- setObject() : void
- Setter method for the object attribute.
- setPlans() : void
- Setter method for the plans attribute.
- setRedeemBy() : void
- Setter method for the redeem_by attribute.
- setRedemptionResource() : void
- Setter method for the redemption_resource attribute.
- setState() : void
- Setter method for the state attribute.
- setTemporalAmount() : void
- Setter method for the temporal_amount attribute.
- setTemporalUnit() : void
- Setter method for the temporal_unit attribute.
- setUniqueCodeTemplate() : void
- Setter method for the unique_code_template attribute.
- setUniqueCouponCode() : void
- Setter method for the unique_coupon_code attribute.
- setUniqueCouponCodesCount() : void
- Setter method for the unique_coupon_codes_count attribute.
- setUpdatedAt() : void
- Setter method for the updated_at attribute.
- encodeApiKey() : string
- Base64 encodes the API key
- getUserAgent() : string
- Generates User-Agent for API requests
- hintArrayType() : string
- The hintArrayType method will provide type hinting for setter methods that have array parameters.
- resourceClass() : string
- Converts a string into a representation of a Recurly Resource
- setResponse() : void
- Setter for the Recurly HTTP Response
- setterParamClass() : string
- Uses the Reflection API to determine what \Recurly\RecurlyResource is the expected parameter for the given method.
- titleize() : string
- Capitalizes all the words in the $input.
Properties
$array_hints
protected
static mixed
$array_hints
= ['setItems' => '\Recurly\Resources\ItemMini', 'setPlans' => '\Recurly\Resources\PlanMini']
$_applies_to_all_items
private
mixed
$_applies_to_all_items
$_applies_to_all_plans
private
mixed
$_applies_to_all_plans
$_applies_to_non_plan_charges
private
mixed
$_applies_to_non_plan_charges
$_code
private
mixed
$_code
$_coupon_type
private
mixed
$_coupon_type
$_created_at
private
mixed
$_created_at
$_discount
private
mixed
$_discount
$_duration
private
mixed
$_duration
$_expired_at
private
mixed
$_expired_at
$_free_trial_amount
private
mixed
$_free_trial_amount
$_free_trial_unit
private
mixed
$_free_trial_unit
$_hosted_page_description
private
mixed
$_hosted_page_description
$_id
private
mixed
$_id
$_invoice_description
private
mixed
$_invoice_description
$_items
private
mixed
$_items
$_max_redemptions
private
mixed
$_max_redemptions
$_max_redemptions_per_account
private
mixed
$_max_redemptions_per_account
$_name
private
mixed
$_name
$_object
private
mixed
$_object
$_plans
private
mixed
$_plans
$_redeem_by
private
mixed
$_redeem_by
$_redemption_resource
private
mixed
$_redemption_resource
$_response
private
mixed
$_response
$_state
private
mixed
$_state
$_temporal_amount
private
mixed
$_temporal_amount
$_temporal_unit
private
mixed
$_temporal_unit
$_unique_code_template
private
mixed
$_unique_code_template
$_unique_coupon_code
private
mixed
$_unique_coupon_code
$_unique_coupon_codes_count
private
mixed
$_unique_coupon_codes_count
$_updated_at
private
mixed
$_updated_at
Methods
__construct()
Constructor
public
final __construct() : mixed
Return values
mixed —__debugInfo()
Override of the magic method __debugInfo that will only return the relevant attributes of the \Recurly\RecurlyResource
public
__debugInfo() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —__set()
Guard against setting invalid properties
public
__set(string $key, mixed $value) : void
Parameters
- $key : string
-
The parameter name that is being set
- $value : mixed
-
The parameter value that is being set
Tags
Return values
void —cast()
Recursively converts a response object into a \Recurly\RecurlyResource.
public
static cast(object $data) : RecurlyResource
Parameters
- $data : object
-
PHP Object containing the decoded JSON
Return values
RecurlyResource —An instance of a Recurly Resource
fromBinary()
Converts a binary response into a Recurly BinaryFile
public
static fromBinary(string $data, Response $response) : BinaryFile
Parameters
- $data : string
-
The binary file data
- $response : Response
-
(optional) The Recurly HTTP Response
Return values
BinaryFile —An instance of a Recurly BinaryFile
fromEmpty()
Returns a \Recurly\EmptyResource for API requests that do not have a response body.
public
static fromEmpty(Response $response) : EmptyResource
Parameters
- $response : Response
-
(optional) The Recurly HTTP Response
Return values
EmptyResource —fromResponse()
Converts a Recurly response object into a \Recurly\RecurlyResource.
public
static fromResponse(Response $response[, object $json = null ]) : RecurlyResource
Parameters
- $response : Response
-
The Recurly HTTP Response
- $json : object = null
-
(optional) JSON payload to use instead of the $response's. Primarily used for errors
Return values
RecurlyResource —An instance of a Recurly Resource
getAppliesToAllItems()
Getter method for the applies_to_all_items attribute.
public
getAppliesToAllItems() : bool|null
The coupon is valid for all items if true. If false then items
will list the applicable items.
Return values
bool|null —getAppliesToAllPlans()
Getter method for the applies_to_all_plans attribute.
public
getAppliesToAllPlans() : bool|null
The coupon is valid for all plans if true. If false then plans
will list the applicable plans.
Return values
bool|null —getAppliesToNonPlanCharges()
Getter method for the applies_to_non_plan_charges attribute.
public
getAppliesToNonPlanCharges() : bool|null
The coupon is valid for one-time, non-plan charges if true.
Return values
bool|null —getCode()
Getter method for the code attribute.
public
getCode() : string|null
The code the customer enters to redeem the coupon.
Return values
string|null —getCouponType()
Getter method for the coupon_type attribute.
public
getCouponType() : string|null
Whether the coupon is "single_code" or "bulk". Bulk coupons will require a unique_code_template
and will generate unique codes through the /generate
endpoint.
Return values
string|null —getCreatedAt()
Getter method for the created_at attribute.
public
getCreatedAt() : string|null
Created at
Return values
string|null —getDiscount()
Getter method for the discount attribute.
public
getDiscount() : CouponDiscount|null
Details of the discount a coupon applies. Will contain a type
property and one of the following properties: percent
, fixed
, trial
.
Return values
CouponDiscount|null —getDuration()
Getter method for the duration attribute.
public
getDuration() : string|null
- "single_use" coupons applies to the first invoice only.
- "temporal" coupons will apply to invoices for the duration determined by the
temporal_unit
andtemporal_amount
attributes.
Return values
string|null —getExpiredAt()
Getter method for the expired_at attribute.
public
getExpiredAt() : string|null
The date and time the coupon was expired early or reached its max_redemptions
.
Return values
string|null —getFreeTrialAmount()
Getter method for the free_trial_amount attribute.
public
getFreeTrialAmount() : int|null
Sets the duration of time the free_trial_unit
is for.
Return values
int|null —getFreeTrialUnit()
Getter method for the free_trial_unit attribute.
public
getFreeTrialUnit() : string|null
Description of the unit of time the coupon is for. Used with free_trial_amount
to determine the duration of time the coupon is for.
Return values
string|null —getHostedPageDescription()
Getter method for the hosted_page_description attribute.
public
getHostedPageDescription() : string|null
This description will show up when a customer redeems a coupon on your Hosted Payment Pages, or if you choose to show the description on your own checkout page.
Return values
string|null —getId()
Getter method for the id attribute.
public
getId() : string|null
Coupon ID
Return values
string|null —getInvoiceDescription()
Getter method for the invoice_description attribute.
public
getInvoiceDescription() : string|null
Description of the coupon on the invoice.
Return values
string|null —getItems()
Getter method for the items attribute.
public
getItems() : array<string|int, mixed>
A list of items for which this coupon applies. This will be
null
if applies_to_all_items=true
.
Return values
array<string|int, mixed> —getMaxRedemptions()
Getter method for the max_redemptions attribute.
public
getMaxRedemptions() : int|null
A maximum number of redemptions for the coupon. The coupon will expire when it hits its maximum redemptions.
Return values
int|null —getMaxRedemptionsPerAccount()
Getter method for the max_redemptions_per_account attribute.
public
getMaxRedemptionsPerAccount() : int|null
Redemptions per account is the number of times a specific account can redeem the coupon. Set redemptions per account to 1
if you want to keep customers from gaming the system and getting more than one discount from the coupon campaign.
Return values
int|null —getName()
Getter method for the name attribute.
public
getName() : string|null
The internal name for the coupon.
Return values
string|null —getObject()
Getter method for the object attribute.
public
getObject() : string|null
Object type
Return values
string|null —getPlans()
Getter method for the plans attribute.
public
getPlans() : array<string|int, mixed>
A list of plans for which this coupon applies. This will be null
if applies_to_all_plans=true
.
Return values
array<string|int, mixed> —getRedeemBy()
Getter method for the redeem_by attribute.
public
getRedeemBy() : string|null
The date and time the coupon will expire and can no longer be redeemed. Time is always 11:59:59, the end-of-day Pacific time.
Return values
string|null —getRedemptionResource()
Getter method for the redemption_resource attribute.
public
getRedemptionResource() : string|null
Whether the discount is for all eligible charges on the account, or only a specific subscription.
Return values
string|null —getResponse()
Getter for the Recurly HTTP Response
public
getResponse() : Response
Return values
Response —The Recurly HTTP Response
getState()
Getter method for the state attribute.
public
getState() : string|null
Indicates if the coupon is redeemable, and if it is not, why.
Return values
string|null —getTemporalAmount()
Getter method for the temporal_amount attribute.
public
getTemporalAmount() : int|null
If duration
is "temporal" than temporal_amount
is an integer which is multiplied by temporal_unit
to define the duration that the coupon will be applied to invoices for.
Return values
int|null —getTemporalUnit()
Getter method for the temporal_unit attribute.
public
getTemporalUnit() : string|null
If duration
is "temporal" than temporal_unit
is multiplied by temporal_amount
to define the duration that the coupon will be applied to invoices for.
Return values
string|null —getUniqueCodeTemplate()
Getter method for the unique_code_template attribute.
public
getUniqueCodeTemplate() : string|null
On a bulk coupon, the template from which unique coupon codes are generated.
Return values
string|null —getUniqueCouponCode()
Getter method for the unique_coupon_code attribute.
public
getUniqueCouponCode() : object|null
Will be populated when the Coupon being returned is a UniqueCouponCode
.
Return values
object|null —getUniqueCouponCodesCount()
Getter method for the unique_coupon_codes_count attribute.
public
getUniqueCouponCodesCount() : int|null
When this number reaches max_redemptions
the coupon will no longer be redeemable.
Return values
int|null —getUpdatedAt()
Getter method for the updated_at attribute.
public
getUpdatedAt() : string|null
Last updated at
Return values
string|null —setAppliesToAllItems()
Setter method for the applies_to_all_items attribute.
public
setAppliesToAllItems(bool $applies_to_all_items) : void
Parameters
- $applies_to_all_items : bool
Return values
void —setAppliesToAllPlans()
Setter method for the applies_to_all_plans attribute.
public
setAppliesToAllPlans(bool $applies_to_all_plans) : void
Parameters
- $applies_to_all_plans : bool
Return values
void —setAppliesToNonPlanCharges()
Setter method for the applies_to_non_plan_charges attribute.
public
setAppliesToNonPlanCharges(bool $applies_to_non_plan_charges) : void
Parameters
- $applies_to_non_plan_charges : bool
Return values
void —setCode()
Setter method for the code attribute.
public
setCode(string $code) : void
Parameters
- $code : string
Return values
void —setCouponType()
Setter method for the coupon_type attribute.
public
setCouponType(string $coupon_type) : void
Parameters
- $coupon_type : string
Return values
void —setCreatedAt()
Setter method for the created_at attribute.
public
setCreatedAt(string $created_at) : void
Parameters
- $created_at : string
Return values
void —setDiscount()
Setter method for the discount attribute.
public
setDiscount(CouponDiscount $discount) : void
Parameters
- $discount : CouponDiscount
Return values
void —setDuration()
Setter method for the duration attribute.
public
setDuration(string $duration) : void
Parameters
- $duration : string
Return values
void —setExpiredAt()
Setter method for the expired_at attribute.
public
setExpiredAt(string $expired_at) : void
Parameters
- $expired_at : string
Return values
void —setFreeTrialAmount()
Setter method for the free_trial_amount attribute.
public
setFreeTrialAmount(int $free_trial_amount) : void
Parameters
- $free_trial_amount : int
Return values
void —setFreeTrialUnit()
Setter method for the free_trial_unit attribute.
public
setFreeTrialUnit(string $free_trial_unit) : void
Parameters
- $free_trial_unit : string
Return values
void —setHostedPageDescription()
Setter method for the hosted_page_description attribute.
public
setHostedPageDescription(string $hosted_page_description) : void
Parameters
- $hosted_page_description : string
Return values
void —setId()
Setter method for the id attribute.
public
setId(string $id) : void
Parameters
- $id : string
Return values
void —setInvoiceDescription()
Setter method for the invoice_description attribute.
public
setInvoiceDescription(string $invoice_description) : void
Parameters
- $invoice_description : string
Return values
void —setItems()
Setter method for the items attribute.
public
setItems(array<string|int, mixed> $items) : void
Parameters
- $items : array<string|int, mixed>
Return values
void —setMaxRedemptions()
Setter method for the max_redemptions attribute.
public
setMaxRedemptions(int $max_redemptions) : void
Parameters
- $max_redemptions : int
Return values
void —setMaxRedemptionsPerAccount()
Setter method for the max_redemptions_per_account attribute.
public
setMaxRedemptionsPerAccount(int $max_redemptions_per_account) : void
Parameters
- $max_redemptions_per_account : int
Return values
void —setName()
Setter method for the name attribute.
public
setName(string $name) : void
Parameters
- $name : string
Return values
void —setObject()
Setter method for the object attribute.
public
setObject(string $object) : void
Parameters
- $object : string
Return values
void —setPlans()
Setter method for the plans attribute.
public
setPlans(array<string|int, mixed> $plans) : void
Parameters
- $plans : array<string|int, mixed>
Return values
void —setRedeemBy()
Setter method for the redeem_by attribute.
public
setRedeemBy(string $redeem_by) : void
Parameters
- $redeem_by : string
Return values
void —setRedemptionResource()
Setter method for the redemption_resource attribute.
public
setRedemptionResource(string $redemption_resource) : void
Parameters
- $redemption_resource : string
Return values
void —setState()
Setter method for the state attribute.
public
setState(string $state) : void
Parameters
- $state : string
Return values
void —setTemporalAmount()
Setter method for the temporal_amount attribute.
public
setTemporalAmount(int $temporal_amount) : void
Parameters
- $temporal_amount : int
Return values
void —setTemporalUnit()
Setter method for the temporal_unit attribute.
public
setTemporalUnit(string $temporal_unit) : void
Parameters
- $temporal_unit : string
Return values
void —setUniqueCodeTemplate()
Setter method for the unique_code_template attribute.
public
setUniqueCodeTemplate(string $unique_code_template) : void
Parameters
- $unique_code_template : string
Return values
void —setUniqueCouponCode()
Setter method for the unique_coupon_code attribute.
public
setUniqueCouponCode(object $unique_coupon_code) : void
Parameters
- $unique_coupon_code : object
Return values
void —setUniqueCouponCodesCount()
Setter method for the unique_coupon_codes_count attribute.
public
setUniqueCouponCodesCount(int $unique_coupon_codes_count) : void
Parameters
- $unique_coupon_codes_count : int
Return values
void —setUpdatedAt()
Setter method for the updated_at attribute.
public
setUpdatedAt(string $updated_at) : void
Parameters
- $updated_at : string
Return values
void —encodeApiKey()
Base64 encodes the API key
protected
static encodeApiKey(string $key) : string
Parameters
- $key : string
-
The API key to encode
Return values
string —base64 encoded API key
getUserAgent()
Generates User-Agent for API requests
protected
static getUserAgent() : string
Return values
string —Recurly client User-Agent string
hintArrayType()
The hintArrayType method will provide type hinting for setter methods that have array parameters.
protected
static hintArrayType(string $key) : string
Parameters
- $key : string
-
The property to get teh type hint for.
Return values
string —The class name of the expected array type.
resourceClass()
Converts a string into a representation of a Recurly Resource
protected
static resourceClass(string $type) : string
Parameters
- $type : string
-
A string to convert to a Recurly Resource
Return values
string —The string representation of a Recurly Resource
setResponse()
Setter for the Recurly HTTP Response
protected
setResponse(Response $response) : void
Parameters
- $response : Response
-
The Recurly HTTP Response
Return values
void —setterParamClass()
Uses the Reflection API to determine what \Recurly\RecurlyResource is the expected parameter for the given method.
protected
static setterParamClass(string $method) : string
Parameters
- $method : string
-
The name of the setter method to find the type hint for
Return values
string —The \Recurly\RecurlyResource that the setter method expects
titleize()
Capitalizes all the words in the $input.
protected
static titleize(string $input[, string $prefix = '' ]) : string
Parameters
- $input : string
-
The string to titleize
- $prefix : string = ''
-
(optional) Prefix to add to the beginning of the titleized string. The prefix will not be titleized.
Return values
string —The titleized $input wtih the prepended $prefix