From 3b835ea26ac72bdae852ee67432ac4a34c5c6a43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Fr=C3=B6ssman?= <thomasf@jossystem.se>
Date: Wed, 20 Jan 2021 09:28:04 +0100
Subject: [PATCH] deprecate a few inconsistently named things and but keep
 aliases.

---
 billing.go          | 35 ++++++++++++++++++++++-------------
 example_test.go     |  4 ++--
 integration_test.go |  6 +++---
 payout.go           |  9 +++++++--
 4 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/billing.go b/billing.go
index 133ac08..9e5de73 100644
--- a/billing.go
+++ b/billing.go
@@ -9,8 +9,8 @@ import (
 )
 
 type (
-	// CreateBillingResp struct
-	CreateBillingResp struct {
+	// CreateBillingResponse struct
+	CreateBillingResponse struct {
 		ID                  string              `json:"id,omitempty"`
 		State               string              `json:"state,omitempty"`
 		PaymentDefinitions  []PaymentDefinition `json:"payment_definitions,omitempty"`
@@ -20,33 +20,42 @@ type (
 		Links               []Link              `json:"links,omitempty"`
 	}
 
-	// CreateAgreementResp struct
-	CreateAgreementResp struct {
+	// CreateBillingResp deprecated, use CreateBillingResponse instead.
+	CreateBillingResp = CreateBillingResponse
+
+	// CreateAgreementResponse struct
+	CreateAgreementResponse struct {
 		Name        string      `json:"name,omitempty"`
 		Description string      `json:"description,omitempty"`
-		Plan        BillingPlan `json:"plan,omitempty"`
+	 	Plan        BillingPlan `json:"plan,omitempty"`
 		Links       []Link      `json:"links,omitempty"`
 		StartTime   time.Time   `json:"start_time,omitempty"`
 	}
 
+	// CreateAgreementResp is deprecated, use CreateAgreementResponse instead.
+	CreateAgreementResp =  CreateAgreementResponse
+
 	// BillingPlanListParams struct
 	BillingPlanListParams struct {
 		ListParams
 		Status string `json:"status,omitempty"` //Allowed values: CREATED, ACTIVE, INACTIVE, ALL.
 	}
 
-	//BillingPlanListResp struct
-	BillingPlanListResp struct {
+	//BillingPlanListResponse struct
+	BillingPlanListResponse struct {
 		SharedListResponse
 		Plans []BillingPlan `json:"plans,omitempty"`
 	}
+
+	// BillingPlanListResp is deprecated, use BillingPlanListResponse instead.
+	BillingPlanListResp = BillingPlanListResponse
 )
 
 // CreateBillingPlan creates a billing plan in Paypal
 // Endpoint: POST /v1/payments/billing-plans
-func (c *Client) CreateBillingPlan(ctx context.Context, plan BillingPlan) (*CreateBillingResp, error) {
+func (c *Client) CreateBillingPlan(ctx context.Context, plan BillingPlan) (*CreateBillingResponse, error) {
 	req, err := c.NewRequest(ctx, http.MethodPost, fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/billing-plans"), plan)
-	response := &CreateBillingResp{}
+	response := &CreateBillingResponse{}
 	if err != nil {
 		return response, err
 	}
@@ -85,14 +94,14 @@ func (c *Client) ActivatePlan(ctx context.Context, planID string) error {
 
 // CreateBillingAgreement creates an agreement for specified plan
 // Endpoint: POST /v1/payments/billing-agreements
-func (c *Client) CreateBillingAgreement(ctx context.Context, a BillingAgreement) (*CreateAgreementResp, error) {
+func (c *Client) CreateBillingAgreement(ctx context.Context, a BillingAgreement) (*CreateAgreementResponse, error) {
 	// PayPal needs only ID, so we will remove all fields except Plan ID
 	a.Plan = BillingPlan{
 		ID: a.Plan.ID,
 	}
 
 	req, err := c.NewRequest(ctx, http.MethodPost, fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/billing-agreements"), a)
-	response := &CreateAgreementResp{}
+	response := &CreateAgreementResponse{}
 	if err != nil {
 		return response, err
 	}
@@ -126,9 +135,9 @@ func (c *Client) ExecuteApprovedAgreement(ctx context.Context, token string) (*E
 
 // ListBillingPlans lists billing-plans
 // Endpoint: GET /v1/payments/billing-plans
-func (c *Client) ListBillingPlans(ctx context.Context, bplp BillingPlanListParams) (*BillingPlanListResp, error) {
+func (c *Client) ListBillingPlans(ctx context.Context, bplp BillingPlanListParams) (*BillingPlanListResponse, error) {
 	req, err := c.NewRequest(ctx, "GET", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/billing-plans"), nil)
-	response := &BillingPlanListResp{}
+	response := &BillingPlanListResponse{}
 	if err != nil {
 		return response, err
 	}
diff --git a/example_test.go b/example_test.go
index 6b0911d..99eda77 100644
--- a/example_test.go
+++ b/example_test.go
@@ -20,7 +20,7 @@ func Example() {
 	}
 }
 
-func ExampleClient_CreateSinglePayout_Venmo() {
+func ExampleClient_CreatePayout_Venmo() {
 	// Initialize client
 	c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
 	if err != nil {
@@ -55,5 +55,5 @@ func ExampleClient_CreateSinglePayout_Venmo() {
 		},
 	}
 
-	c.CreateSinglePayout(context.Background(), payout)
+	c.CreatePayout(context.Background(), payout)
 }
diff --git a/integration_test.go b/integration_test.go
index f977851..afd1960 100644
--- a/integration_test.go
+++ b/integration_test.go
@@ -65,12 +65,12 @@ func TestCreateVenmoPayout(t *testing.T) {
 		},
 	}
 
-	res, err := c.CreateSinglePayout(context.Background(), payout)
+	res, err := c.CreatePayout(context.Background(), payout)
 	assert.NoError(t, err, "should accept venmo wallet")
 	assert.Greater(t, len(res.Items), 0)
 }
 
-func TestCreateSinglePayout(t *testing.T) {
+func TestCreatePayout(t *testing.T) {
 	c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
 	c.GetAccessToken(context.Background())
 
@@ -94,7 +94,7 @@ func TestCreateSinglePayout(t *testing.T) {
 		},
 	}
 
-	c.CreateSinglePayout(context.Background(), payout)
+	c.CreatePayout(context.Background(), payout)
 }
 
 func TestStoreCreditCard(t *testing.T) {
diff --git a/payout.go b/payout.go
index 4de1d0b..e74c920 100644
--- a/payout.go
+++ b/payout.go
@@ -5,10 +5,10 @@ import (
 	"fmt"
 )
 
-// CreateSinglePayout submits a payout with an asynchronous API call, which immediately returns the results of a PayPal payment.
+// CreatePayout submits a payout with an asynchronous API call, which immediately returns the results of a PayPal payment.
 // For email payout set RecipientType: "EMAIL" and receiver email into Receiver
 // Endpoint: POST /v1/payments/payouts
-func (c *Client) CreateSinglePayout(ctx context.Context, p Payout) (*PayoutResponse, error) {
+func (c *Client) CreatePayout(ctx context.Context, p Payout) (*PayoutResponse, error) {
 	req, err := c.NewRequest(ctx, "POST", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/payouts"), p)
 	response := &PayoutResponse{}
 
@@ -23,6 +23,11 @@ func (c *Client) CreateSinglePayout(ctx context.Context, p Payout) (*PayoutRespo
 	return response, nil
 }
 
+// CreateSinglePayout is deprecated, use CreatePayout instead.
+func (c *Client) CreateSinglePayout(ctx context.Context, p Payout) (*PayoutResponse, error) {
+	return c.CreatePayout(ctx, p)
+}
+
 // GetPayout shows the latest status of a batch payout along with the transaction status and other data for individual items.
 // Also, returns IDs for the individual payout items. You can use these item IDs in other calls.
 // Endpoint: GET /v1/payments/payouts/ID