Skip to content

Commit

Permalink
Merge pull request #120 from VictorAvelar/feature/onboarding-api-reso…
Browse files Browse the repository at this point in the history
…urce

onboarding api resource
  • Loading branch information
VictorAvelar authored Mar 7, 2021
2 parents 77a83ff + 2cfecd0 commit 72de0e8
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ changelog:
exclude:
- docs
- changelog
- ^Merge pull request
- readme
- ^Merge pull request
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## master

## v2.6.0

### Added

- OnboardingService
- GetOnboardingData method
- SubmitOnboardingData method

## v2.5.1

### Fixed
Expand Down
14 changes: 7 additions & 7 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## Supported Versions

Even though go offers full backwards compatibility, this package will only be concerned about the versions tested and
declared inside the `.travis.yml` file.
Even though go offers full backwards compatibility, this package will only be concerned about the versions tested and
declared inside the `.scrutinizer.yml` file.

| Version | Supported |
| ------- | ------------------ |
| 1.13.x | :warning: |
| 1.14.x | :warning: |
| 1.15.x | :warning: |
| 1.16.x | :white_check_mark: |
| master | :x: |
| 1.13.x | :warning: |
| 1.14.x | :warning: |
| 1.15.x | :white_check_mark: |
| 1.16.x | :white_check_mark: |
| master | :x: |

## Reporting a Vulnerability

Expand Down
109 changes: 109 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ type Client struct {
Miscellaneous *MiscellaneousService
Mandates *MandatesService
Permissions *PermissionsService
Onboarding *OnboardingService
}
```

Expand Down Expand Up @@ -1285,6 +1286,114 @@ const (

Valid modes

#### type Onboarding

```go
type Onboarding struct {
Resource string `json:"reference,omitempty"`
Name string `json:"name,omitempty"`
SignedUpAt *time.Time `json:"signedUpAt,omitempty"`
Status OnboardingStatus `json:"status,omitempty"`
CanReceivePayments bool `json:"canReceivePayments,omitempty"`
CanReveiceSettlements bool `json:"canReceiveSettlements,omitempty"`
Links OnboardingLinks `json:"_links,omitempty"`
}
```

Onboarding data for an organization.

#### type OnboardingData

```go
type OnboardingData struct {
Organization struct {
Name string `json:"name,omitempty"`
Address *Address `json:"address,omitempty"`
RegistrationNumber string `json:"registrationNumber,omitempty"`
VatNumber string `json:"vatNumber,omitempty"`
VatRegulation string `json:"vatRegulation,omitempty"`
} `json:"organization,omitempty"`
Profile struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
Description string `json:"description,omitempty"`
Phone string `json:"phone,omitempty"`
CategoryCode CategoryCode `json:"categoryCode,omitempty"`
} `json:"profile,omitempty"`
}
```

OnboardingData request possible values.

Please note that even though all parameters are optional, at least one of them
needs to be provided in the request.

Information that the merchant has entered in their dashboard will not be
overwritten.

#### type OnboardingLinks

```go
type OnboardingLinks struct {
Self *URL `json:"self,omitempty"`
Dashboard *URL `json:"dashboard,omitempty"`
Organization *URL `json:"organization,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}
```

OnboardingLinks contains URL objects relevant to the onboarding status.

#### type OnboardingService

```go
type OnboardingService service
```

OnboardingService operates over the onboarding API.

#### func (\*OnboardingService) GetOnboardingStatus

```go
func (os *OnboardingService) GetOnboardingStatus() (o *Onboarding, err error)
```

GetOnboardingStatus gets the status of onboarding of the authenticated
organization.

See: https://docs.mollie.com/reference/v2/onboarding-api/get-onboarding-status

#### func (\*OnboardingService) SubmitOnboardingData

```go
func (os *OnboardingService) SubmitOnboardingData(d *OnboardingData) (err error)
```

SubmitOnboardingData sends data that will be prefilled in the merchant’s
onboarding. Please note that the data you submit will only be processed when the
onboarding status is needs-data.

See: https://docs.mollie.com/reference/v2/onboarding-api/submit-onboarding-data

#### type OnboardingStatus

```go
type OnboardingStatus string
```

OnboardingStatus describes status of the organization’s onboarding process.

```go
const (
NeedsDataOnboardingStatus OnboardingStatus = "needs-data"
InReviewOnboardingStatus OnboardingStatus = "in-review"
CompletedOnboardingStatus OnboardingStatus = "completed"
)
```

Possible status values.

#### type Order

```go
Expand Down
2 changes: 2 additions & 0 deletions mollie/mollie.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Client struct {
Miscellaneous *MiscellaneousService
Mandates *MandatesService
Permissions *PermissionsService
Onboarding *OnboardingService
}

type service struct {
Expand Down Expand Up @@ -176,6 +177,7 @@ func NewClient(baseClient *http.Client, c *Config) (mollie *Client, err error) {
mollie.Miscellaneous = (*MiscellaneousService)(&mollie.common)
mollie.Mandates = (*MandatesService)(&mollie.common)
mollie.Permissions = (*PermissionsService)(&mollie.common)
mollie.Onboarding = (*OnboardingService)(&mollie.common)

// Parse authorization from specified environment variable
tkn, ok := os.LookupEnv(c.auth)
Expand Down
104 changes: 104 additions & 0 deletions mollie/onboarding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package mollie

import (
"encoding/json"
"net/http"
"time"
)

const onboardingTarget = "v2/onboarding/me"

// OnboardingStatus describes status of the organization’s onboarding process.
type OnboardingStatus string

// Possible status values.
const (
NeedsDataOnboardingStatus OnboardingStatus = "needs-data"
InReviewOnboardingStatus OnboardingStatus = "in-review"
CompletedOnboardingStatus OnboardingStatus = "completed"
)

// OnboardingService operates over the onboarding API.
type OnboardingService service

// OnboardingLinks contains URL objects relevant to the onboarding status.
type OnboardingLinks struct {
Self *URL `json:"self,omitempty"`
Dashboard *URL `json:"dashboard,omitempty"`
Organization *URL `json:"organization,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}

// Onboarding data for an organization.
type Onboarding struct {
Resource string `json:"reference,omitempty"`
Name string `json:"name,omitempty"`
SignedUpAt *time.Time `json:"signedUpAt,omitempty"`
Status OnboardingStatus `json:"status,omitempty"`
CanReceivePayments bool `json:"canReceivePayments,omitempty"`
CanReveiceSettlements bool `json:"canReceiveSettlements,omitempty"`
Links OnboardingLinks `json:"_links,omitempty"`
}

// GetOnboardingStatus gets the status of onboarding of the authenticated organization.
//
// See: https://docs.mollie.com/reference/v2/onboarding-api/get-onboarding-status
func (os *OnboardingService) GetOnboardingStatus() (o *Onboarding, err error) {
req, err := os.client.NewAPIRequest(http.MethodGet, onboardingTarget, nil)
if err != nil {
return
}

res, err := os.client.Do(req)
if err != nil {
return
}

if err = json.Unmarshal(res.content, &o); err != nil {
return
}

return
}

// OnboardingData request possible values.
//
// Please note that even though all parameters are optional,
// at least one of them needs to be provided in the request.
//
// Information that the merchant has entered in their dashboard will not be overwritten.
type OnboardingData struct {
Organization struct {
Name string `json:"name,omitempty"`
Address *Address `json:"address,omitempty"`
RegistrationNumber string `json:"registrationNumber,omitempty"`
VatNumber string `json:"vatNumber,omitempty"`
VatRegulation string `json:"vatRegulation,omitempty"`
} `json:"organization,omitempty"`
Profile struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
Description string `json:"description,omitempty"`
Phone string `json:"phone,omitempty"`
CategoryCode CategoryCode `json:"categoryCode,omitempty"`
} `json:"profile,omitempty"`
}

// SubmitOnboardingData sends data that will be prefilled in the merchant’s onboarding.
// Please note that the data you submit will only be processed when the onboarding status is needs-data.
//
// See: https://docs.mollie.com/reference/v2/onboarding-api/submit-onboarding-data
func (os *OnboardingService) SubmitOnboardingData(d *OnboardingData) (err error) {
req, err := os.client.NewAPIRequest(http.MethodPost, onboardingTarget, d)
if err != nil {
return
}

_, err = os.client.Do(req)
if err != nil {
return
}

return
}
Loading

0 comments on commit 72de0e8

Please sign in to comment.