Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Class representing the API constraints on mail clasess.

This is a weird bit of data-in-code, but since we're open sourcing this lib, I think it is the right way to go.

Also: Git gui doesn't know about untracked files. So that is why this is in its own commit.
  • Loading branch information...
commit cc9e14b0bb626e6ad9cc6ca105cdcbe1d69c34f1 1 parent c05554c
@robacarp robacarp authored
Showing with 43 additions and 0 deletions.
  1. +43 −0 Shipping/Endicia/MailClass.php
View
43 Shipping/Endicia/MailClass.php
@@ -0,0 +1,43 @@
+<?php
+namespace SparkLib\Shipping\Endicia;
+
+class MailClass {
+ public $name;
+ public $international;
+ public $integrated_form;
+ public $max_items;
+
+ public function __construct($name, $international = false, $integrated_form = null, $max_items = null){
+ $this->name = $name;
+ $this->international = $international;
+ $this->integrated_form = $integrated_form;
+ $this->max_items = $max_items;
+ }
+
+ public static function Express() { return new static('Express'); }
+ public static function First() { return new static('First'); }
+ public static function LibraryMail() { return new static('LibraryMail'); }
+ public static function MediaMail() { return new static('MediaMail'); }
+ public static function StandardPost() { return new static('StandardPost'); }
+ public static function ParcelSelect() { return new static('ParcelSelect'); }
+ public static function Priority() { return new static('Priority'); }
+ public static function CriticalMail() { return new static('CriticalMail'); }
+
+ public static function FirstClassMailInternational() { return new static('FirstClassMailInternational', true, 'Form2976', 5); }
+ public static function FirstClassPackageInternationalService() { return new static('FirstClassPackageInternationalService', true, 'Form2976', 5); }
+ public static function PriorityMailInternational() { return new static('PriorityMailInternational', true, 'Form2976A'); }
+ public static function ExpressMailInternational() { return new static('ExpressMailInternational', true, 'Form2976A'); }
+
+ public static function fromString($str) {
+ if ( method_exists(get_class(), $str) ){
+ return static::$str();
+ } else {
+ return null;
+ }
+ }
+
+ public function isInternational(){
+ return isset($this->international) && $this->international;
+ }
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.