From f19599359688904405f76ee582048a7093dfa8a1 Mon Sep 17 00:00:00 2001 From: Cameron Jarnot <48696097+cameronjarnot1@users.noreply.github.com> Date: Tue, 20 Jul 2021 00:37:55 -0600 Subject: [PATCH] deletions made (#209) --- billing_agreements.go | 70 ------------------------------------------- types.go | 30 ------------------- unit_test.go | 45 ---------------------------- 3 files changed, 145 deletions(-) delete mode 100644 billing_agreements.go diff --git a/billing_agreements.go b/billing_agreements.go deleted file mode 100644 index 21be8f7f..00000000 --- a/billing_agreements.go +++ /dev/null @@ -1,70 +0,0 @@ -package paypal - -import ( - "context" - "fmt" -) - -// CreateBillingAgreementToken - Use this call to create a billing agreement -// Endpoint: POST /v1/billing-agreements/agreement-tokens -func (c *Client) CreateBillingAgreementToken( - ctx context.Context, - name string, - description string, - startDate string, - payer *Payer, - plan *BillingPlan, -) (*BillingAgreementToken, error) { - type createBARequest struct { - Name string `json:"name"` - Description string `json:"description"` - StartDate string `json:"start_date"` - Payer *Payer `json:"payer"` - Plan *BillingPlan `json:"plan"` - } - - billingAgreementToken := &BillingAgreementToken{} - - req, err := c.NewRequest( - ctx, - "POST", - fmt.Sprintf("%s%s", c.APIBase, "/v1/billing-agreements/agreement-tokens"), - createBARequest{Name: name, Description: description, StartDate: startDate, Payer: payer, Plan: plan}) - if err != nil { - return nil, err - } - - if err = c.SendWithAuth(req, billingAgreementToken); err != nil { - return billingAgreementToken, err - } - - return billingAgreementToken, nil -} - -// CreateBillingAgreementFromToken - Use this call to create a billing agreement -// Endpoint: POST /v1/billing-agreements/agreements -func (c *Client) CreateBillingAgreementFromToken( - ctx context.Context, - tokenID string, -) (*BillingAgreement, error) { - type createBARequest struct { - TokenID string `json:"token_id"` - } - - billingAgreement := &BillingAgreement{} - - req, err := c.NewRequest( - ctx, - "POST", - fmt.Sprintf("%s%s", c.APIBase, "/v1/billing-agreements/agreements"), - createBARequest{TokenID: tokenID}) - if err != nil { - return nil, err - } - - if err = c.SendWithAuth(req, billingAgreement); err != nil { - return billingAgreement, err - } - - return billingAgreement, nil -} diff --git a/types.go b/types.go index 71d547b8..a9875fe3 100644 --- a/types.go +++ b/types.go @@ -328,36 +328,6 @@ type ( OverrideMerchantPreferences *MerchantPreferences `json:"override_merchant_preferences,omitempty"` } - // BillingAgreementToken response struct - BillingAgreementToken struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - StartDate string `json:"start_date,omitempty"` - AgreementDetails *AgreementDetails `json:"agreement_details,omitempty"` - Payer *Payer `json:"payer,omitempty"` - ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` - OverrideMerchantPreferences *MerchantPreferences `json:"override_merchant_preferences,omitempty"` - OverrideChargeModels *OverrideChargeModel `json:"override_charge_models,omitempty"` - Plan *Plan `json:"plan,omitempty"` - } - - //OverrideChargeModel struct - OverrideChargeModel struct { - ChargeID string `json:"charge_id"` - Amount *Amount `json:"amount"` - } - - // Plan struct - Plan struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - CreateTime string `json:"create_time,omitempty"` - UpdateTime string `json:"update_time,omitempty"` - PaymentDefinitions []PaymentDefinition `json:"payment_definitions,omitempty"` - } - // BillingInfo struct BillingInfo struct { OutstandingBalance AmountPayout `json:"outstanding_balance,omitempty"` diff --git a/unit_test.go b/unit_test.go index d8e15938..ab8b8d0b 100644 --- a/unit_test.go +++ b/unit_test.go @@ -392,16 +392,6 @@ func (ts *webprofileTestServer) ServeHTTP(w http.ResponseWriter, r *http.Request ts.deleteinvalid(w, r) } } - if r.RequestURI == "/v1/billing-agreements/agreement-tokens" { - if r.Method == "POST" { - ts.create(w, r) - } - } - if r.RequestURI == "/v1/billing-agreements/agreements" { - if r.Method == "POST" { - ts.createWithoutName(w, r) - } - } } func (ts *webprofileTestServer) create(w http.ResponseWriter, r *http.Request) { @@ -781,39 +771,4 @@ func TestDeleteWebProfile_invalid(t *testing.T) { t.Fatal(err) } -} - -func TestCreateBillingAgreementToken(t *testing.T) { - - ts := httptest.NewServer(&webprofileTestServer{t: t}) - defer ts.Close() - - c, _ := NewClient("foo", "bar", ts.URL) - - _, err := c.CreateBillingAgreementToken( - context.Background(), - "name A", - "description A", - "start date A", - &Payer{PaymentMethod: "paypal"}, - &BillingPlan{ID: "id B", Name: "name B", Description: "description B", Type: "type B"}) - - if err != nil { - t.Fatal(err) - } - -} - -func TestCreateBillingAgreementFromToken(t *testing.T) { - - ts := httptest.NewServer(&webprofileTestServer{t: t}) - defer ts.Close() - - c, _ := NewClient("foo", "bar", ts.URL) - - _, err := c.CreateBillingAgreementFromToken(context.Background(),"BillingAgreementToken") - - if err != nil { - t.Fatal(err) - } } \ No newline at end of file