PHP Class WC_Connect_API_Client, woocommerce-connect-client

Show file Open project: Automattic/woocommerce-connect-client Class Usage Examples

Protected Properties

Property Type Description
$validator WC_Connect_Services_Validator
$wc_connect_loader WC_Connect_Loader

Public Methods

Method Description
__construct ( WC_Connect_Service_Schemas_Validator $validator, WC_Connect_Loader $wc_connect_loader )
auth_test ( ) : true | WP_Error Tests the connection to the Connect for WooCommerce Server
get_label_rates ( array $request ) : object | WP_Error Gets shipping rates (for labels) from the Connect for WooCommerce Server
get_label_status ( $label_id ) : object | WP_Error Gets the shipping label status (refund status, tracking code, etc)
get_labels_preview_pdf ( $request ) : object | WP_Error Gets a PDF with the set of dummy labels specified in the request
get_labels_print_pdf ( $request ) : object | WP_Error Gets a PDF with the requested shipping labels in it
get_payment_methods ( ) : mixed | WP_Error Asks the Connect for WooCommerce server for an array of payment methods
get_service_schemas ( ) : array | WP_Error Requests the available services for this site from the Connect for WooCommerce Server
get_shipping_rates ( $services, $package, $boxes ) : object | WP_Error Gets shipping rates (for checkout) from the Connect for WooCommerce Server
send_address_normalization_request ( $body )
send_shipping_label_refund_request ( $label_id ) : object | WP_Error Request a refund for a given shipping label
send_shipping_label_request ( $body )
validate_service_settings ( $service_slug, $service_settings ) : boolean | WP_Error Validates the settings for a given service with the Connect for WooCommerce Server

Protected Methods

Method Description
authorization_header ( )
request ( $method, $path, $body = [] ) : mixed | WP_Error Sends a request to the Connect for WooCommerce Server
request_body ( array $initial_body = [] ) : array Adds useful WP/WC/WCC information to request bodies
request_headers ( ) : array | WP_Error Generates headers for our request to the Connect for WooCommerce Server
request_signature ( $token_key, $token_secret, $timestamp, $nonce, $time_diff )

Private Methods

Method Description
generate_guid ( ) : string Generates a GUID.
get_guid ( )

Method Details

__construct() public method

public __construct ( WC_Connect_Service_Schemas_Validator $validator, WC_Connect_Loader $wc_connect_loader )
$validator WC_Connect_Service_Schemas_Validator
$wc_connect_loader WC_Connect_Loader

auth_test() public method

Tests the connection to the Connect for WooCommerce Server
public auth_test ( ) : true | WP_Error
return true | WP_Error

authorization_header() protected method

protected authorization_header ( )

get_label_rates() public method

Gets shipping rates (for labels) from the Connect for WooCommerce Server
public get_label_rates ( array $request ) : object | WP_Error
$request array - array( 'packages' => array( array( 'id' => 'box_1', 'height' => 10, 'length' => 10, 'width' => 10, 'weight' => 10, ), array( 'id' => 'box_2', 'box_id' => 'medium_flat_box_top', 'weight' => 5, ), ... ), 'carrier' => 'usps', 'origin' => array( 'address' => '132 Hawthorne St', 'address_2' => '', 'city' => 'San Francisco', 'state' => 'CA', 'postcode' => '94107', 'country' => 'US', ), 'destination' => array( 'address' => '1550 Snow Creek Dr', 'address_2' => '', 'city' => 'Park City', 'state' => 'UT', 'postcode' => '84060', 'country' => 'US', ), )
return object | WP_Error

get_label_status() public method

Gets the shipping label status (refund status, tracking code, etc)
public get_label_status ( $label_id ) : object | WP_Error
$label_id integer
return object | WP_Error

get_labels_preview_pdf() public method

Gets a PDF with the set of dummy labels specified in the request
public get_labels_preview_pdf ( $request ) : object | WP_Error
$request
return object | WP_Error

get_labels_print_pdf() public method

Gets a PDF with the requested shipping labels in it
public get_labels_print_pdf ( $request ) : object | WP_Error
$request
return object | WP_Error

get_payment_methods() public method

Asks the Connect for WooCommerce server for an array of payment methods
public get_payment_methods ( ) : mixed | WP_Error
return mixed | WP_Error

get_service_schemas() public method

Requests the available services for this site from the Connect for WooCommerce Server
public get_service_schemas ( ) : array | WP_Error
return array | WP_Error

get_shipping_rates() public method

Gets shipping rates (for checkout) from the Connect for WooCommerce Server
public get_shipping_rates ( $services, $package, $boxes ) : object | WP_Error
$services All settings for all services we want rates for
$package Package provided to WC_Shipping_Method::calculate_shipping()
return object | WP_Error

request() protected method

Sends a request to the Connect for WooCommerce Server
protected request ( $method, $path, $body = [] ) : mixed | WP_Error
$method
$path
$body
return mixed | WP_Error

request_body() protected method

Adds useful WP/WC/WCC information to request bodies
protected request_body ( array $initial_body = [] ) : array
$initial_body array
return array

request_headers() protected method

Generates headers for our request to the Connect for WooCommerce Server
protected request_headers ( ) : array | WP_Error
return array | WP_Error

request_signature() protected method

protected request_signature ( $token_key, $token_secret, $timestamp, $nonce, $time_diff )

send_address_normalization_request() public method

send_shipping_label_refund_request() public method

Request a refund for a given shipping label
public send_shipping_label_refund_request ( $label_id ) : object | WP_Error
$label_id integer
return object | WP_Error

send_shipping_label_request() public method

public send_shipping_label_request ( $body )

validate_service_settings() public method

Validates the settings for a given service with the Connect for WooCommerce Server
public validate_service_settings ( $service_slug, $service_settings ) : boolean | WP_Error
$service_slug
$service_settings
return boolean | WP_Error

Property Details

$validator protected property

protected WC_Connect_Services_Validator $validator
return WC_Connect_Services_Validator

$wc_connect_loader protected property

protected WC_Connect_Loader $wc_connect_loader
return WC_Connect_Loader