This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
forked from Vonage/vonage-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly generated code. CreateCall working.
- Loading branch information
Showing
11 changed files
with
300 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nexmo | ||
|
||
import "github.com/dghubble/sling" | ||
|
||
type ApplicationService struct { | ||
sling *sling.Sling | ||
authSet *AuthSet | ||
} | ||
|
||
func newApplicationService(base *sling.Sling, authSet *AuthSet) *ApplicationService { | ||
sling := base.Base("https://api.nexmo.com/v1/applications") | ||
return &ApplicationService{ | ||
sling: sling, | ||
authSet: authSet, | ||
} | ||
} | ||
|
||
func (c *ApplicationService) SetBaseURL(baseURL string) { | ||
c.sling.Base(baseURL) | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nexmo | ||
|
||
import "github.com/dghubble/sling" | ||
|
||
type CallService struct { | ||
sling *sling.Sling | ||
authSet *AuthSet | ||
} | ||
|
||
func newCallService(base *sling.Sling, authSet *AuthSet) *CallService { | ||
sling := base.Base("https://api.nexmo.com/v1/calls") | ||
return &CallService{ | ||
sling: sling, | ||
authSet: authSet, | ||
} | ||
} | ||
|
||
func (c *CallService) SetBaseURL(baseURL string) { | ||
c.sling.Base(baseURL) | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package nexmo | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
func (c *CallErrorResponse) Error() string { | ||
return fmt.Sprintf("%s: %s", c.ErrorTitle, c.Type) | ||
} | ||
|
||
func (c *CallService) CreateCall(request CreateCallRequest) (*CreateCallResponse, *http.Response, error) { | ||
sling := c.sling.New().Post("").BodyJSON(request) | ||
err := c.authSet.ApplyJWT(sling) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("%s - error applying JWT", err) | ||
} | ||
|
||
callResponse := new(CreateCallResponse) | ||
errorResponse := new(CallErrorResponse) | ||
httpResponse, err := sling.Receive(callResponse, errorResponse) | ||
if err != nil { | ||
return nil, httpResponse, fmt.Errorf("%s - error receiving data from server", err) | ||
} | ||
if errorResponse.Type != "" { | ||
return nil, httpResponse, errorResponse | ||
} | ||
return callResponse, httpResponse, nil | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nexmo | ||
|
||
import "github.com/dghubble/sling" | ||
|
||
type DeveloperService struct { | ||
sling *sling.Sling | ||
authSet *AuthSet | ||
} | ||
|
||
func newDeveloperService(base *sling.Sling, authSet *AuthSet) *DeveloperService { | ||
sling := base.Base("https://rest.nexmo.com/account/") | ||
return &DeveloperService{ | ||
sling: sling, | ||
authSet: authSet, | ||
} | ||
} | ||
|
||
func (c *DeveloperService) SetBaseURL(baseURL string) { | ||
c.sling.Base(baseURL) | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nexmo | ||
|
||
import "github.com/dghubble/sling" | ||
|
||
type InsightService struct { | ||
sling *sling.Sling | ||
authSet *AuthSet | ||
} | ||
|
||
func newInsightService(base *sling.Sling, authSet *AuthSet) *InsightService { | ||
sling := base.Base("https://api.nexmo.com/ni/") | ||
return &InsightService{ | ||
sling: sling, | ||
authSet: authSet, | ||
} | ||
} | ||
|
||
func (c *InsightService) SetBaseURL(baseURL string) { | ||
c.sling.Base(baseURL) | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nexmo | ||
|
||
import "github.com/dghubble/sling" | ||
|
||
type SMSService struct { | ||
sling *sling.Sling | ||
authSet *AuthSet | ||
} | ||
|
||
func newSMSService(base *sling.Sling, authSet *AuthSet) *SMSService { | ||
sling := base.Base("https://rest.nexmo.com") | ||
return &SMSService{ | ||
sling: sling, | ||
authSet: authSet, | ||
} | ||
} | ||
|
||
func (c *SMSService) SetBaseURL(baseURL string) { | ||
c.sling.Base(baseURL) | ||
} | ||
|
Oops, something went wrong.