This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subscription = Recurly::Subscription.create( | |
:plan_code => 'standard', | |
:currency => 'USD', | |
:add_ons => [{ | |
:add_on => { | |
:add_on_code => 'extraip', | |
:quantity => 1 | |
} | |
}], | |
:account => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$subscription = Recurly_Subscription::get('17caaca1716f33572edc8146e0aaefde'); | |
$add_on = new Recurly_SubscriptionAddOn(); | |
$add_on->quantity = 2; | |
$add_on->add_on_code = 'extraip'; | |
$subscription->subscription_add_ons[] = $add_on; | |
$subscription->updateImmediately(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Account struct | |
type Account struct{ | |
account_code, username,email, state, first_name string | |
last_name, company_name, accept_language string | |
hosted_login_token, created_at string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Account struct | |
type Account struct{ | |
XMLName xml.Name `xml:"account"` | |
AccountCode string `xml:"account_code"` | |
Username string `xml:"username"` | |
Email string `xml:"email"` | |
State string `xml:"state,omitempty"` | |
FirstName string `xml:"first_name"` | |
LastName string `xml:"last_name"` | |
CompanyName string `xml:"company_name"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
account Account | |
//resp is http.Response from http.Client | |
if body, readerr := ioutil.ReadAll(resp.Body); readerr == nil { | |
//load object xml | |
if xmlerr := xml.Unmarshal(body, &account); xmlerr != nil { | |
return xmlerr | |
} | |
} else { | |
//return read error | |
return readerr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Generic Reader | |
type nopCloser struct { | |
io.Reader | |
} | |
//update function | |
func (a *Account) Update() error { | |
if xmlstring, err := xml.MarshalIndent(a, "", " "); err == nil { | |
xmlstring = []byte(xml.Header + string(xmlstring)) | |
client := &http.Client{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
$subscription = new Recurly_Subscription(); | |
$account = Recurly_Account::get('1'); //this will throw a not found exception if the account_code does not exist | |
$subscription->account = $account; | |
$subscription->create(); //this will throw a validation error exception as there are missing fields | |
} | |
catch (Exception $e) { | |
//for a list of possible exception types go to | |
//https://github.com/recurly/recurly-client-php/blob/master/lib/recurly/errors.php | |
//you could use send these messages to a log for later analysis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ { | |
"type" : "WatchEvent", | |
"actor" : { | |
"avatar_url" : "https://secure.gravatar.com/avatar/f873c249ce2812e897cdd3eb8cc697ea?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", | |
"url" : "https://api.github.com/users/pkorotkov", | |
"id" : 532567, | |
"gravatar_id" : "f873c249ce2812e897cdd3eb8cc697ea", | |
"login" : "pkorotkov" | |
}, | |
"repo" : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsondata []interface{} | |
err := json.Unmarshal(rawData, &jsondata) | |
if err == nil{ | |
m := v.(map[string]interface{}) | |
//the following prints out the type | |
fmt.Printf("%s \n",m["type"]) | |
} else { | |
fmt.Println("error:", err) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type" : "CreateEvent", | |
"actor" : { | |
"avatar_url" : "https://secure.gravatar.com/avatar/05abda697c2654a02391248bed3a5f3e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", | |
"url" : "https://api.github.com/users/mbeale", | |
"id" : 1507647, | |
"gravatar_id" : "05abda697c2654a02391248bed3a5f3e", | |
"login" : "mbeale" | |
}, | |
"repo" : { |
OlderNewer