From e70e544c1a1d9ecabc13ddfb5eb2cd8d115c9a1c Mon Sep 17 00:00:00 2001 From: Alex Pliutau Date: Wed, 21 Aug 2019 15:50:20 +0200 Subject: [PATCH] Update package name --- README.md | 44 ++++++++++++++++++++++---------------------- authorization.go | 2 +- billing.go | 2 +- billing_test.go | 40 +++++++++++++++++++--------------------- client.go | 6 +++--- doc.go | 10 +++++----- example_test.go | 6 +++--- filter.go | 2 +- filter_test.go | 2 +- identity.go | 2 +- integration_test.go | 2 +- order.go | 2 +- payout.go | 2 +- sale.go | 2 +- types.go | 2 +- unit_test.go | 2 +- vault.go | 2 +- webprofile.go | 6 +++--- 18 files changed, 67 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 69054f2..a6683c6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![Go Report Card](https://goreportcard.com/badge/plutov/PayPal-Go-SDK)](https://goreportcard.com/report/plutov/PayPal-Go-SDK) -[![Build Status](https://travis-ci.org/plutov/PayPal-Go-SDK.svg?branch=master)](https://travis-ci.org/plutov/PayPal-Go-SDK) -[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/plutov/PayPal-Go-SDK) +[![Go Report Card](https://goreportcard.com/badge/plutov/paypal)](https://goreportcard.com/report/plutov/paypal) +[![Build Status](https://travis-ci.org/plutov/paypal.svg?branch=master)](https://travis-ci.org/plutov/paypal) +[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/plutov/paypal) ### Go client for PayPal REST API @@ -43,15 +43,15 @@ Currently supports **v2** only, if you want to use **v1**, use **v1.1.4** git ta * POST /v2/payments/billing-agreements/***TOKEN***/agreement-execute ### Missing endpoints -It is possible that some endpoints are missing in this SDK Client, but you can use built-in **paypalsdk** functions to perform a request: **NewClient -> NewRequest -> SendWithAuth** +It is possible that some endpoints are missing in this SDK Client, but you can use built-in **paypal** functions to perform a request: **NewClient -> NewRequest -> SendWithAuth** ### New Client ```go -import "github.com/plutov/PayPal-Go-SDK" +import "github.com/plutov/paypal" // Create a client instance -c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox) +c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox) c.SetLog(os.Stdout) // Set log to terminal stdout accessToken, err := c.GetAccessToken() @@ -66,7 +66,7 @@ auth, err := c.GetAuthorization("2DC87612EK520411B") ### Capture authorization ```go -capture, err := c.CaptureAuthorization(authID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"}, true) +capture, err := c.CaptureAuthorization(authID, &paypal.Amount{Total: "7.00", Currency: "USD"}, true) ``` ### Void authorization @@ -78,7 +78,7 @@ auth, err := c.VoidAuthorization(authID) ### Reauthorize authorization ```go -auth, err := c.ReauthorizeAuthorization(authID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"}) +auth, err := c.ReauthorizeAuthorization(authID, &paypal.Amount{Total: "7.00", Currency: "USD"}) ``` ### Get Sale by ID @@ -93,7 +93,7 @@ sale, err := c.GetSale("36C38912MN9658832") // Full refund, err := c.RefundSale(saleID, nil) // Partial -refund, err := c.RefundSale(saleID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"}) +refund, err := c.RefundSale(saleID, &paypal.Amount{Total: "7.00", Currency: "USD"}) ``` ### Get Refund by ID @@ -111,25 +111,25 @@ order, err := c.GetOrder("O-4J082351X3132253H") ### Create an Order ```go -order, err := c.CreateOrder(paypalsdk.OrderIntentCapture, []paypalsdk.PurchaseUnitRequest{paypalsdk.PurchaseUnitRequest{ReferenceID: "ref-id", Amount: paypalsdk.Amount{Total: "7.00", Currency: "USD"}}}) +order, err := c.CreateOrder(paypal.OrderIntentCapture, []paypal.PurchaseUnitRequest{paypal.PurchaseUnitRequest{ReferenceID: "ref-id", Amount: paypal.Amount{Total: "7.00", Currency: "USD"}}}) ``` ### Update Order by ID ```go -order, err := c.UpdateOrder("O-4J082351X3132253H", []paypalsdk.PurchaseUnitRequest{}) +order, err := c.UpdateOrder("O-4J082351X3132253H", []paypal.PurchaseUnitRequest{}) ``` ### Authorize Order ```go -auth, err := c.AuthorizeOrder(orderID, paypalsdk.AuthorizeOrderRequest{}) +auth, err := c.AuthorizeOrder(orderID, paypal.AuthorizeOrderRequest{}) ``` ### Capture Order ```go -capture, err := c.CaptureOrder(orderID, paypalsdk.CaptureOrderRequest{}) +capture, err := c.CaptureOrder(orderID, paypal.CaptureOrderRequest{}) ``` ### Identity @@ -149,15 +149,15 @@ userInfo, err := c.GetUserInfo("openid") ### Create single payout to email ```go -payout := paypalsdk.Payout{ - SenderBatchHeader: &paypalsdk.SenderBatchHeader{ +payout := paypal.Payout{ + SenderBatchHeader: &paypal.SenderBatchHeader{ EmailSubject: "Subject will be displayed on PayPal", }, - Items: []paypalsdk.PayoutItem{ - paypalsdk.PayoutItem{ + Items: []paypal.PayoutItem{ + paypal.PayoutItem{ RecipientType: "EMAIL", Receiver: "single-email-payout@mail.com", - Amount: &paypalsdk.AmountPayout{ + Amount: &paypal.AmountPayout{ Value: "15.11", Currency: "USD", }, @@ -247,7 +247,7 @@ err := c.DeleteWebProfile("XP-CP6S-W9DY-96H8-MVN2") ```go // Store CC -c.StoreCreditCard(paypalsdk.CreditCard{ +c.StoreCreditCard(paypal.CreditCard{ Number: "4417119669820331", Type: "visa", ExpireMonth: "11", @@ -261,8 +261,8 @@ c.StoreCreditCard(paypalsdk.CreditCard{ c.DeleteCreditCard("CARD-ID-123") // Edit it -c.PatchCreditCard("CARD-ID-123", []paypalsdk.CreditCardField{ - paypalsdk.CreditCardField{ +c.PatchCreditCard("CARD-ID-123", []paypal.CreditCardField{ + paypal.CreditCardField{ Operation: "replace", Path: "/billing_address/line1", Value: "New value", @@ -290,5 +290,5 @@ Current contributors: ### Tests -* Unit tests: `go test` +* Unit tests: `go test -v ./...` * Integration tests: `go test -tags=integration` diff --git a/authorization.go b/authorization.go index cc792d8..30c5300 100644 --- a/authorization.go +++ b/authorization.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "bytes" diff --git a/billing.go b/billing.go index 390cbb5..d105eef 100644 --- a/billing.go +++ b/billing.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "bytes" diff --git a/billing_test.go b/billing_test.go index 7ee8c8f..39aea42 100644 --- a/billing_test.go +++ b/billing_test.go @@ -1,39 +1,37 @@ -package paypalsdk_test +package paypal_test import ( "fmt" "time" - - pp "github.com/plutov/PayPal-Go-SDK" ) func BillingExample() { - plan := pp.BillingPlan{ + plan := BillingPlan{ Name: "Plan with Regular and Trial Payment Definitions", Description: "Plan with regular and trial payment definitions.", Type: "fixed", - PaymentDefinitions: []pp.PaymentDefinition{ + PaymentDefinitions: []PaymentDefinition{ { Name: "Regular payment definition", Type: "REGULAR", Frequency: "MONTH", FrequencyInterval: "2", - Amount: pp.AmountPayout{ + Amount: AmountPayout{ Value: "100", Currency: "USD", }, Cycles: "12", - ChargeModels: []pp.ChargeModel{ + ChargeModels: []ChargeModel{ { Type: "SHIPPING", - Amount: pp.AmountPayout{ + Amount: AmountPayout{ Value: "10", Currency: "USD", }, }, { Type: "TAX", - Amount: pp.AmountPayout{ + Amount: AmountPayout{ Value: "12", Currency: "USD", }, @@ -45,22 +43,22 @@ func BillingExample() { Type: "trial", Frequency: "week", FrequencyInterval: "5", - Amount: pp.AmountPayout{ + Amount: AmountPayout{ Value: "9.19", Currency: "USD", }, Cycles: "2", - ChargeModels: []pp.ChargeModel{ + ChargeModels: []ChargeModel{ { Type: "SHIPPING", - Amount: pp.AmountPayout{ + Amount: AmountPayout{ Value: "1", Currency: "USD", }, }, { Type: "TAX", - Amount: pp.AmountPayout{ + Amount: AmountPayout{ Value: "2", Currency: "USD", }, @@ -68,8 +66,8 @@ func BillingExample() { }, }, }, - MerchantPreferences: &pp.MerchantPreferences{ - SetupFee: &pp.AmountPayout{ + MerchantPreferences: &MerchantPreferences{ + SetupFee: &AmountPayout{ Value: "1", Currency: "USD", }, @@ -80,7 +78,7 @@ func BillingExample() { MaxFailAttempts: "0", }, } - c, err := pp.NewClient("clientID", "secretID", pp.APIBaseSandBox) + c, err := NewClient("clientID", "secretID", APIBaseSandBox) if err != nil { panic(err) } @@ -94,18 +92,18 @@ func BillingExample() { } err = c.ActivatePlan(planResp.ID) fmt.Println(err) - agreement := pp.BillingAgreement{ + agreement := BillingAgreement{ Name: "Fast Speed Agreement", Description: "Agreement for Fast Speed Plan", - StartDate: pp.JSONTime(time.Now().Add(time.Hour * 24)), - Plan: pp.BillingPlan{ID: planResp.ID}, - Payer: pp.Payer{ + StartDate: JSONTime(time.Now().Add(time.Hour * 24)), + Plan: BillingPlan{ID: planResp.ID}, + Payer: Payer{ PaymentMethod: "paypal", }, } resp, err := c.CreateBillingAgreement(agreement) fmt.Println(err, resp) - bps, err := c.ListBillingPlans(pp.BillingPlanListParams{Status: "ACTIVE"}) + bps, err := c.ListBillingPlans(BillingPlanListParams{Status: "ACTIVE"}) fmt.Println(err, bps) } diff --git a/client.go b/client.go index 159c785..d5432bc 100644 --- a/client.go +++ b/client.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "bytes" @@ -13,7 +13,7 @@ import ( ) // NewClient returns new Client struct -// APIBase is a base API URL, for testing you can use paypalsdk.APIBaseSandBox +// APIBase is a base API URL, for testing you can use paypal.APIBaseSandBox func NewClient(clientID string, secret string, APIBase string) (*Client, error) { if clientID == "" || secret == "" || APIBase == "" { return nil, errors.New("ClientID, Secret and APIBase are required to create a Client") @@ -65,7 +65,7 @@ func (c *Client) SetAccessToken(token string) { } // SetLog will set/change the output destination. -// If log file is set paypalsdk will log all requests and responses to this Writer +// If log file is set paypal will log all requests and responses to this Writer func (c *Client) SetLog(log io.Writer) { c.Log = log } diff --git a/doc.go b/doc.go index 7fd5294..6d36f5a 100644 --- a/doc.go +++ b/doc.go @@ -1,10 +1,10 @@ /* -Package paypalsdk provides a wrapper to PayPal API (https://developer.paypal.com/webapps/developer/docs/api/). -The first thing you do is to create a Client (you can select API base URL using paypalsdk contants). - c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox) +Package paypal provides a wrapper to PayPal API (https://developer.paypal.com/webapps/developer/docs/api/). +The first thing you do is to create a Client (you can select API base URL using paypal contants). + c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox) Then you can get an access token from PayPal: accessToken, err := c.GetAccessToken() After you have an access token you can call built-in functions to get data from PayPal. -paypalsdk will assign all responses to go structures. +paypal will assign all responses to go structures. */ -package paypalsdk +package paypal diff --git a/example_test.go b/example_test.go index 715cc41..3973024 100644 --- a/example_test.go +++ b/example_test.go @@ -1,10 +1,10 @@ -package paypalsdk_test +package paypal_test -import paypalsdk "github.com/plutov/PayPal-Go-SDK" +import paypal "github.com/plutov/paypal" func Example() { // Initialize client - c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox) + c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox) if err != nil { panic(err) } diff --git a/filter.go b/filter.go index 33aabd2..61b28d7 100644 --- a/filter.go +++ b/filter.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "fmt" diff --git a/filter_test.go b/filter_test.go index 1791269..a9f2062 100644 --- a/filter_test.go +++ b/filter_test.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "testing" diff --git a/identity.go b/identity.go index f59fa98..4a7b495 100644 --- a/identity.go +++ b/identity.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "fmt" diff --git a/integration_test.go b/integration_test.go index ad067b9..b8b5a04 100644 --- a/integration_test.go +++ b/integration_test.go @@ -1,6 +1,6 @@ // +build integration -package paypalsdk +package paypal import ( "testing" diff --git a/order.go b/order.go index 8b71819..a9a6067 100644 --- a/order.go +++ b/order.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import "fmt" diff --git a/payout.go b/payout.go index 86b5056..512c630 100644 --- a/payout.go +++ b/payout.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "fmt" diff --git a/sale.go b/sale.go index f1a75e6..89d5f1d 100644 --- a/sale.go +++ b/sale.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import "fmt" diff --git a/types.go b/types.go index bea6254..3638141 100644 --- a/types.go +++ b/types.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "encoding/json" diff --git a/unit_test.go b/unit_test.go index f2d3c02..4134af1 100644 --- a/unit_test.go +++ b/unit_test.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "encoding/json" diff --git a/vault.go b/vault.go index ec361cb..42195ad 100644 --- a/vault.go +++ b/vault.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "fmt" diff --git a/webprofile.go b/webprofile.go index 55af2fb..09b455c 100644 --- a/webprofile.go +++ b/webprofile.go @@ -1,4 +1,4 @@ -package paypalsdk +package paypal import ( "fmt" @@ -44,7 +44,7 @@ func (c *Client) GetWebProfile(profileID string) (*WebProfile, error) { } if wp.ID == "" { - return &wp, fmt.Errorf("paypalsdk: unable to get web profile with ID = %s", profileID) + return &wp, fmt.Errorf("paypal: unable to get web profile with ID = %s", profileID) } return &wp, nil @@ -76,7 +76,7 @@ func (c *Client) GetWebProfiles() ([]WebProfile, error) { func (c *Client) SetWebProfile(wp WebProfile) error { if wp.ID == "" { - return fmt.Errorf("paypalsdk: no ID specified for WebProfile") + return fmt.Errorf("paypal: no ID specified for WebProfile") } url := fmt.Sprintf("%s%s%s", c.APIBase, "/v1/payment-experience/web-profiles/", wp.ID)