How to use NewClient method of secret Package

Best Testkube code snippet using secret.NewClient

integration_test.go

Source:integration_test.go Github

copy

Full Screen

...13var testPayerID = "CR87QHB7JTRSC"14var testUserID = "https://www.paypal.com/webapps/auth/identity/user/WEssgRpQij92sE99_F9MImvQ8FPYgUEjrvCja2qH2H8"15var testCardID = "CARD-54E6956910402550WKGRL6EA"16func TestGetAccessToken(t *testing.T) {17 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)18 token, err := c.GetAccessToken()19 if err != nil {20 t.Errorf("Not expected error for GetAccessToken(), got %s", err.Error())21 }22 if token.Token == "" {23 t.Errorf("Expected non-empty token for GetAccessToken()")24 }25}26func TestGetAuthorization(t *testing.T) {27 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)28 c.GetAccessToken()29 _, err := c.GetAuthorization(testAuthID)30 if err == nil {31 t.Errorf("GetAuthorization expects error")32 }33}34func TestCaptureAuthorization(t *testing.T) {35 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)36 c.GetAccessToken()37 _, err := c.CaptureAuthorization(testAuthID, &Amount{Total: "200", Currency: "USD"}, true)38 if err == nil {39 t.Errorf("Auth is expired, 400 error must be returned")40 }41}42func TestVoidAuthorization(t *testing.T) {43 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)44 c.GetAccessToken()45 _, err := c.VoidAuthorization(testAuthID)46 if err == nil {47 t.Errorf("Auth is expired, 400 error must be returned")48 }49}50func TestReauthorizeAuthorization(t *testing.T) {51 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)52 c.GetAccessToken()53 _, err := c.ReauthorizeAuthorization(testAuthID, &Amount{Total: "200", Currency: "USD"})54 if err == nil {55 t.Errorf("Reauthorization not allowed for this product, 500 error must be returned")56 }57}58func TestGrantNewAccessTokenFromAuthCode(t *testing.T) {59 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)60 _, err := c.GrantNewAccessTokenFromAuthCode("123", "http://example.com/myapp/return.php")61 if err == nil {62 t.Errorf("GrantNewAccessTokenFromAuthCode must return error for invalid code")63 }64}65func TestGrantNewAccessTokenFromRefreshToken(t *testing.T) {66 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)67 _, err := c.GrantNewAccessTokenFromRefreshToken("123")68 if err == nil {69 t.Errorf("GrantNewAccessTokenFromRefreshToken must return error for invalid refresh token")70 }71}72func TestGetUserInfo(t *testing.T) {73 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)74 c.GetAccessToken()75 u, err := c.GetUserInfo("openid")76 if u.ID != testUserID || err != nil {77 t.Errorf("GetUserInfo must return valid test ID=%s, error: %v", testUserID, err)78 }79}80func TestGetOrder(t *testing.T) {81 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)82 c.GetAccessToken()83 _, err := c.GetOrder(testOrderID)84 if err == nil {85 t.Errorf("GetOrder expects error")86 }87}88func TestAuthorizeOrder(t *testing.T) {89 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)90 c.GetAccessToken()91 _, err := c.AuthorizeOrder(testOrderID, &Amount{Total: "7.00", Currency: "USD"})92 if err == nil {93 t.Errorf("Order is expired, 400 error must be returned")94 }95}96func TestCaptureOrder(t *testing.T) {97 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)98 c.GetAccessToken()99 _, err := c.CaptureOrder(testOrderID, &Amount{Total: "100", Currency: "USD"}, true, nil)100 if err == nil {101 t.Errorf("Order is expired, 400 error must be returned")102 }103}104func TestVoidOrder(t *testing.T) {105 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)106 c.GetAccessToken()107 _, err := c.VoidOrder(testOrderID)108 if err == nil {109 t.Errorf("Order is expired, 400 error must be returned")110 }111}112func TestCreateDirectPaypalPayment(t *testing.T) {113 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)114 c.GetAccessToken()115 amount := Amount{116 Total: "15.11",117 Currency: "USD",118 }119 p, err := c.CreateDirectPaypalPayment(amount, "http://example.com", "http://example.com", "test payment")120 if err != nil || p.ID == "" {121 t.Errorf("Test paypal payment is not created, err: %v", err)122 }123}124func TestCreatePayment(t *testing.T) {125 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)126 c.GetAccessToken()127 p := Payment{128 Intent: "sale",129 Payer: &Payer{130 PaymentMethod: "credit_card",131 FundingInstruments: []FundingInstrument{{132 CreditCard: &CreditCard{133 Number: "4111111111111111",134 Type: "visa",135 ExpireMonth: "11",136 ExpireYear: "2020",137 CVV2: "777",138 FirstName: "John",139 LastName: "Doe",140 },141 }},142 },143 Transactions: []Transaction{{144 Amount: &Amount{145 Currency: "USD",146 Total: "10.00", // total cost including shipping147 Details: Details{148 Shipping: "3.00", // total shipping cost149 Subtotal: "7.00", // total cost without shipping150 },151 },152 Description: "My Payment",153 ItemList: &ItemList{154 Items: []Item{155 Item{156 Quantity: 2,157 Price: "3.50",158 Currency: "USD",159 Name: "Product 1",160 },161 },162 },163 }},164 RedirectURLs: &RedirectURLs{165 ReturnURL: "http://..",166 CancelURL: "http://..",167 },168 }169 _, err := c.CreatePayment(p)170 if err == nil {171 t.Errorf("Expected error")172 }173}174func TestGetPayment(t *testing.T) {175 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)176 c.GetAccessToken()177 _, err := c.GetPayment(testPaymentID)178 if err == nil {179 t.Errorf("404 for this payment ID")180 }181}182func TestGetPayments(t *testing.T) {183 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)184 c.GetAccessToken()185 _, err := c.GetPayments()186 if err != nil {187 t.Errorf("Nil error expected, got: %s", err.Error())188 }189}190func TestPatchPayment(t *testing.T) {191 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)192 c.GetAccessToken()193 p := Payment{194 Intent: "sale",195 Payer: &Payer{196 PaymentMethod: "paypal",197 },198 Transactions: []Transaction{{199 Amount: &Amount{200 Currency: "USD",201 Total: "10.00", // total cost including shipping202 Details: Details{203 Shipping: "3.00", // total shipping cost204 Subtotal: "7.00", // total cost without shipping205 },206 },207 Description: "My Payment",208 ItemList: &ItemList{209 Items: []Item{210 Item{211 Quantity: 2,212 Price: "3.50",213 Currency: "USD",214 Name: "Product 1",215 },216 },217 },218 Custom: "First value",219 }},220 RedirectURLs: &RedirectURLs{221 ReturnURL: "http://..",222 CancelURL: "http://..",223 },224 }225 NewPayment, err := c.CreatePayment(p)226 if err != nil {227 t.Errorf("Unexpected error %v", err)228 }229 PaymentID := NewPayment.ID230 pp := []PaymentPatch{231 {232 Operation: "replace",233 Path: "/transactions/0/custom",234 Value: "Replaced Value",235 },236 }237 RevisedPayment, errpp := c.PatchPayment(PaymentID, pp)238 if errpp != nil {239 t.Errorf("Unexpected error when patching %v", errpp)240 }241 if RevisedPayment.Transactions != nil &&242 len(RevisedPayment.Transactions) > 0 &&243 RevisedPayment.Transactions[0].Custom != "" {244 if RevisedPayment.Transactions[0].Custom != "Replaced Value" {245 t.Errorf("Patched payment value failed to be patched %v", RevisedPayment.Transactions[0].Custom)246 }247 }248}249func TestExecuteApprovedPayment(t *testing.T) {250 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)251 c.GetAccessToken()252 _, err := c.ExecuteApprovedPayment(testPaymentID, testPayerID)253 if err == nil {254 t.Errorf("404 for this payment ID")255 }256}257func TestCreateSinglePayout(t *testing.T) {258 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)259 c.GetAccessToken()260 payout := Payout{261 SenderBatchHeader: &SenderBatchHeader{262 EmailSubject: "Subject will be displayed on PayPal",263 },264 Items: []PayoutItem{265 {266 RecipientType: "EMAIL",267 Receiver: "single-email-payout@mail.com",268 Amount: &AmountPayout{269 Value: "15.11",270 Currency: "USD",271 },272 Note: "Optional note",273 SenderItemID: "Optional Item ID",274 },275 },276 }277 _, err := c.CreateSinglePayout(payout)278 if err != nil {279 t.Errorf("Test single payout is not created, error: %v", err)280 }281}282func TestGetSale(t *testing.T) {283 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)284 c.GetAccessToken()285 _, err := c.GetSale(testSaleID)286 if err == nil {287 t.Errorf("404 must be returned for ID=%s", testSaleID)288 }289}290func TestRefundSale(t *testing.T) {291 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)292 c.GetAccessToken()293 _, err := c.RefundSale(testSaleID, nil)294 if err == nil {295 t.Errorf("404 must be returned for ID=%s", testSaleID)296 }297 _, err = c.RefundSale(testSaleID, &Amount{Total: "7.00", Currency: "USD"})298 if err == nil {299 t.Errorf("404 must be returned for ID=%s", testSaleID)300 }301}302func TestGetRefund(t *testing.T) {303 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)304 c.GetAccessToken()305 _, err := c.GetRefund("1")306 if err == nil {307 t.Errorf("404 must be returned for ID=%s", testSaleID)308 }309}310func TestStoreCreditCard(t *testing.T) {311 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)312 c.GetAccessToken()313 r1, e1 := c.StoreCreditCard(CreditCard{})314 if e1 == nil || r1 != nil {315 t.Errorf("Error is expected for invalid CC")316 }317 r2, e2 := c.StoreCreditCard(CreditCard{318 Number: "4417119669820331",319 Type: "visa",320 ExpireMonth: "11",321 ExpireYear: "2020",322 CVV2: "874",323 FirstName: "Foo",324 LastName: "Bar",325 })326 if e2 != nil || r2 == nil {327 t.Errorf("200 code expected for valid CC card. Error: %v", e2)328 }329}330func TestDeleteCreditCard(t *testing.T) {331 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)332 c.GetAccessToken()333 e1 := c.DeleteCreditCard("")334 if e1 == nil {335 t.Errorf("Error is expected for invalid CC ID")336 }337}338func TestGetCreditCard(t *testing.T) {339 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)340 c.GetAccessToken()341 r1, e1 := c.GetCreditCard("BBGGG")342 if e1 == nil || r1 != nil {343 t.Errorf("Error is expected for invalid CC, got CC %v", r1)344 }345}346func TestGetCreditCards(t *testing.T) {347 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)348 c.GetAccessToken()349 r1, e1 := c.GetCreditCards(nil)350 if e1 != nil || r1 == nil {351 t.Errorf("200 code expected. Error: %v", e1)352 }353 r2, e2 := c.GetCreditCards(&CreditCardsFilter{354 Page: 2,355 PageSize: 7,356 })357 if e2 != nil || r2 == nil {358 t.Errorf("200 code expected. Error: %v", e2)359 }360}361func TestPatchCreditCard(t *testing.T) {362 c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)363 c.GetAccessToken()364 r1, e1 := c.PatchCreditCard(testCardID, nil)365 if e1 == nil || r1 != nil {366 t.Errorf("Error is expected for empty update info")367 }368}...

Full Screen

Full Screen

client_test.go

Source:client_test.go Github

copy

Full Screen

...23 headers := make(map[string][]string)24 headers["custom_header_1"] = append(headers["custom_header_1"], "value_1")2526 // Create a new client27 newClient, err := NewClient(28 WithCredentials(testClientID, testClientSecret),29 WithCustomHeaders(headers),30 WithCustomHTTPClient(client),31 WithHost(testHost),32 WithRedirectURI(testRedirectURI),33 WithRequestTracing(),34 )35 if err != nil {36 return nil, err37 }3839 // Return the mocking client40 return newClient, nil41}4243// TestNewClient will test the method NewClient()44func TestNewClient(t *testing.T) {4546 t.Run("missing client_id", func(t *testing.T) {47 customHTTPClient := resty.New()48 customHTTPClient.SetTimeout(defaultHTTPTimeout)49 httpmock.ActivateNonDefault(customHTTPClient.GetClient())5051 newClient, err := NewClient(52 WithCredentials("", testClientSecret),53 WithCustomHTTPClient(customHTTPClient),54 )55 assert.Error(t, err)56 assert.Nil(t, newClient)57 })5859 t.Run("missing client_secret", func(t *testing.T) {60 customHTTPClient := resty.New()61 customHTTPClient.SetTimeout(defaultHTTPTimeout)62 httpmock.ActivateNonDefault(customHTTPClient.GetClient())6364 newClient, err := NewClient(65 WithCredentials(testClientID, ""),66 WithCustomHTTPClient(customHTTPClient),67 )68 assert.Error(t, err)69 assert.Nil(t, newClient)70 })7172 t.Run("test client, get access token, defaults", func(t *testing.T) {73 c, err := newTestClient()74 assert.NoError(t, err)75 assert.NotNil(t, c)7677 mockUpdateApplicationAccessToken()78 err = c.UpdateApplicationAccessToken()79 assert.NoError(t, err)80 assert.NotNil(t, c.options.token)8182 assert.Equal(t, defaultHTTPTimeout, c.options.httpTimeout)83 assert.Equal(t, defaultRetryCount, c.options.retryCount)84 assert.Equal(t, defaultUserAgent, c.options.userAgent)8586 assert.Equal(t, testTokenType, c.options.token.TokenType)87 assert.Equal(t, testExpiresIn, c.options.token.ExpiresIn)88 assert.Equal(t, time.Now().UTC().Unix()+c.options.token.ExpiresIn, c.options.token.ExpiresAt)89 assert.Equal(t, testAccessToken, c.options.token.AccessToken)90 assert.Equal(t, testClientID, c.options.clientID)91 assert.Equal(t, testClientSecret, c.options.clientSecret)92 assert.Equal(t, testRedirectURI, c.options.redirectURI)93 assert.Equal(t, testHost, c.options.host)94 })9596 t.Run("custom HTTP client", func(t *testing.T) {97 customHTTPClient := resty.New()98 customHTTPClient.SetTimeout(defaultHTTPTimeout)99 httpmock.ActivateNonDefault(customHTTPClient.GetClient())100101 newClient, err := NewClient(102 WithCredentials(testClientID, testClientSecret),103 WithCustomHTTPClient(customHTTPClient),104 )105 assert.NoError(t, err)106 assert.NotNil(t, newClient)107 })108109 t.Run("custom HTTP timeout", func(t *testing.T) {110 newClient, err := NewClient(111 WithCredentials(testClientID, testClientSecret),112 WithHTTPTimeout(15*time.Second),113 )114 assert.NoError(t, err)115 assert.NotNil(t, newClient)116 assert.Equal(t, 15*time.Second, newClient.options.httpTimeout)117 })118119 t.Run("custom host", func(t *testing.T) {120 newClient, err := NewClient(121 WithCredentials(testClientID, testClientSecret),122 WithHost(testHost),123 )124 assert.NoError(t, err)125 assert.NotNil(t, newClient)126 assert.Equal(t, testHost, newClient.options.host)127 })128129 t.Run("custom retry count", func(t *testing.T) {130 newClient, err := NewClient(131 WithCredentials(testClientID, testClientSecret),132 WithRetryCount(4),133 )134 assert.NoError(t, err)135 assert.NotNil(t, newClient)136 assert.Equal(t, 4, newClient.options.retryCount)137 })138139 t.Run("custom user agent", func(t *testing.T) {140 newClient, err := NewClient(141 WithCredentials(testClientID, testClientSecret),142 WithUserAgent("custom-user-agent"),143 )144 assert.NoError(t, err)145 assert.NotNil(t, newClient)146 assert.Equal(t, "custom-user-agent", newClient.options.userAgent)147 })148149 t.Run("custom headers", func(t *testing.T) {150 customHTTPClient := resty.New()151 httpmock.ActivateNonDefault(customHTTPClient.GetClient())152153 headers := make(map[string][]string)154 headers["custom_header_1"] = append(headers["custom_header_1"], "value_1")155 headers["custom_header_2"] = append(headers["custom_header_2"], "value_1")156 headers["custom_header_2"] = append(headers["custom_header_2"], "value_2")157 client, err := NewClient(158 WithCredentials(testClientID, testClientSecret),159 WithCustomHTTPClient(customHTTPClient),160 WithCustomHeaders(headers),161 )162 assert.NoError(t, err)163 assert.NotNil(t, client)164 assert.Equal(t, 2, len(client.options.customHeaders))165 assert.Equal(t, []string{"value_1"}, client.options.customHeaders["custom_header_1"])166 })167168 t.Run("auto-load the application token", func(t *testing.T) {169 customHTTPClient := resty.New()170 httpmock.ActivateNonDefault(customHTTPClient.GetClient())171 mockUpdateApplicationAccessToken()172173 client, err := NewClient(174 WithHost(testHost),175 WithCredentials(testClientID, testClientSecret),176 WithCustomHTTPClient(customHTTPClient),177 WithAutoLoadToken(),178 )179 assert.NoError(t, err)180 assert.NotNil(t, client)181 assert.NotNil(t, client.Token())182 })183184 t.Run("auto-load fails", func(t *testing.T) {185 customHTTPClient := resty.New()186 httpmock.ActivateNonDefault(customHTTPClient.GetClient())187 mockAccessTokenFailed(http.StatusBadRequest)188189 client, err := NewClient(190 WithHost(testHost),191 WithCredentials(testClientID, testClientSecret),192 WithCustomHTTPClient(customHTTPClient),193 WithAutoLoadToken(),194 )195 assert.Error(t, err)196 assert.Nil(t, client)197 assert.Nil(t, client.Token())198 })199200 t.Run("override the application access token", func(t *testing.T) {201 newClient, err := NewClient(202 WithCredentials(testClientID, testClientSecret),203 WithHTTPTimeout(15*time.Second),204 WithApplicationAccessToken(DotAccessToken{205 AccessToken: testAccessToken,206 ExpiresAt: time.Now().UTC().Unix() + testExpiresIn,207 ExpiresIn: testExpiresIn,208 TokenType: testTokenType,209 }),210 )211 assert.NoError(t, err)212 assert.NotNil(t, newClient)213214 token := newClient.Token()215 assert.Equal(t, testAccessToken, token.AccessToken)216 })217}218219// TestClient_GetUserAgent will test the method GetUserAgent()220func TestClient_GetUserAgent(t *testing.T) {221 t.Run("get user agent", func(t *testing.T) {222 c, err := newTestClient()223 assert.NoError(t, err)224 assert.NotNil(t, c)225 userAgent := c.GetUserAgent()226 assert.Equal(t, defaultUserAgent, userAgent)227 })228}229230// TestClient_NewState will test the method NewState()231func TestClient_NewState(t *testing.T) {232 t.Run("generate a new state", func(t *testing.T) {233 c, err := newTestClient()234 assert.NoError(t, err)235 assert.NotNil(t, c)236237 var state string238 state, err = c.NewState()239 assert.NoError(t, err)240 assert.Equal(t, 64, len(state))241 })242}243244// TestClient_Token will test the method Token()245func TestClient_Token(t *testing.T) {246 t.Run("token is present", func(t *testing.T) {247 c, err := newTestClient()248 assert.NoError(t, err)249 assert.NotNil(t, c)250251 mockUpdateApplicationAccessToken()252 err = c.UpdateApplicationAccessToken()253 assert.NoError(t, err)254255 token := c.Token()256 assert.NotNil(t, token)257 })258259 t.Run("token is not present", func(t *testing.T) {260 c, err := newTestClient()261 assert.NoError(t, err)262 assert.NotNil(t, c)263264 mockAccessTokenFailed(http.StatusBadRequest)265 err = c.UpdateApplicationAccessToken()266 assert.Error(t, err)267268 token := c.Token()269 assert.Nil(t, token)270 })271}272273// ExampleNewClient example using NewClient()274//275// See more examples in /examples/276func ExampleNewClient() {277 client, err := NewClient(278 WithCredentials("your-client-id", "your-secret-id"),279 WithRedirectURI("http://localhost:3000/v1/auth/dotwallet/callback"),280 )281 if err != nil {282 fmt.Printf("error loading client: %s", err.Error())283 return284 }285 fmt.Printf("loaded client: %s", client.options.userAgent)286 // Output:loaded client: dotwallet-go-sdk: v0.0.3287}288289// BenchmarkNewClient benchmarks the method NewClient()290func BenchmarkNewClient(b *testing.B) {291 for i := 0; i < b.N; i++ {292 _, _ = NewClient(293 WithCredentials(testClientID, testClientSecret),294 )295 }296}297298// TestDefaultClientOptions will test the method defaultClientOptions()299func TestDefaultClientOptions(t *testing.T) {300 options := defaultClientOptions()301 assert.NotNil(t, options)302303 assert.Equal(t, defaultHost, options.host)304 assert.Equal(t, defaultHTTPTimeout, options.httpTimeout)305 assert.Equal(t, defaultRetryCount, options.retryCount)306 assert.Equal(t, defaultUserAgent, options.userAgent) ...

Full Screen

Full Screen

shapeways_test.go

Source:shapeways_test.go Github

copy

Full Screen

1package shapeways_test2import (3 "github.com/Shapeways/go-shapeways/shapeways"4)5func ExampleNewClient() {6 client := shapeways.NewClient(7 "MY CONSUMER KEY",8 "MY CONSUMER SECRET",9 "http://localhost/callback",10 )11 // If the user has been authed before then12 // explicitly set their token/secret13 client.OauthCredentials.Token = "USERS TOKEN"14 client.OauthCredentials.Secret = "USERS SECRET"15}16func ExampleClient_Connect() {17 client := shapeways.NewClient(18 "MY CONSUMER KEY",19 "MY CONSUMER SECRET",20 "http://localhost/callback",21 )22 authUrl, err := client.Connect()23 if err != nil {24 // handle error25 }26 // access oauth secret27 client.OauthCredentials.Secret28 // send user to authUrl29}30func ExampleClient_Verify() {31 client := shapeways.NewClient(32 "MY CONSUMER KEY",33 "MY CONSUMER SECRET",34 "http://localhost/callback",35 )36 // parse token and verifier from oauth callback37 err := client.Verify(token, verifier)38 if err != nil {39 // handle error40 }41 // access oauth token/secret42 client.OauthCredentials.Token43 client.OauthCredentials.Secret44}45func ExampleClient_VerifyURL() {46 client := shapeways.NewClient(47 "MY CONSUMER KEY",48 "MY CONSUMER SECRET",49 "http://localhost/callback",50 )51 // raw callback url from oauth callback52 err := client.VerifyURL(callbackUrl)53 if err != nil {54 // handle error55 }56 // access oauth token/secret57 client.OauthCredentials.Token58 client.OauthCredentials.Secret59}60func ExampleClient_Url() {61 client := shapeways.NewClient(62 "MY CONSUMER KEY",63 "MY CONSUMER SECRET",64 "http://localhost/callback",65 )66 fmt.Printf(client.Url("/api/"))67 // Output: https://api.shapeways.com/api/v1/68}69func ExampleClient_GetApiInfo() {70 client := shapeways.NewClient(71 "MY CONSUMER KEY",72 "MY CONSUMER SECRET",73 "http://localhost/callback",74 )75 // set users token/secret76 client.OauthCredentials.Token = "TOKEN"77 client.OauthCredentials.Secret = "SECRET"78 results, err := client.GetApiInfo()79}80func ExampleClient_GetCart() {81 client := shapeways.NewClient(82 "MY CONSUMER KEY",83 "MY CONSUMER SECRET",84 "http://localhost/callback",85 )86 // set users token/secret87 client.OauthCredentials.Token = "TOKEN"88 client.OauthCredentials.Secret = "SECRET"89 results, err := client.GetCart()90}91func ExampleClient_GetCategories() {92 client := shapeways.NewClient(93 "MY CONSUMER KEY",94 "MY CONSUMER SECRET",95 "http://localhost/callback",96 )97 // set users token/secret98 client.OauthCredentials.Token = "TOKEN"99 client.OauthCredentials.Secret = "SECRET"100 results, err := client.GetCategories()101}102func ExampleClient_GetCategory() {103 client := shapeways.NewClient(104 "MY CONSUMER KEY",105 "MY CONSUMER SECRET",106 "http://localhost/callback",107 )108 // set users token/secret109 client.OauthCredentials.Token = "TOKEN"110 client.OauthCredentials.Secret = "SECRET"111 results, err := client.GetCategory(7)112}113func ExampleClient_GetMaterial() {114 client := shapeways.NewClient(115 "MY CONSUMER KEY",116 "MY CONSUMER SECRET",117 "http://localhost/callback",118 )119 // set users token/secret120 client.OauthCredentials.Token = "TOKEN"121 client.OauthCredentials.Secret = "SECRET"122 results, err := client.GetMaterial(25)123}124func ExampleClient_GetMaterials() {125 client := shapeways.NewClient(126 "MY CONSUMER KEY",127 "MY CONSUMER SECRET",128 "http://localhost/callback",129 )130 // set users token/secret131 client.OauthCredentials.Token = "TOKEN"132 client.OauthCredentials.Secret = "SECRET"133 results, err := client.GetMaterials()134}135func ExampleClient_GetModel() {136 client := shapeways.NewClient(137 "MY CONSUMER KEY",138 "MY CONSUMER SECRET",139 "http://localhost/callback",140 )141 // set users token/secret142 client.OauthCredentials.Token = "TOKEN"143 client.OauthCredentials.Secret = "SECRET"144 results, err := client.GetModel(1670823)145}146func ExampleClient_GetModels() {147 client := shapeways.NewClient(148 "MY CONSUMER KEY",149 "MY CONSUMER SECRET",150 "http://localhost/callback",151 )152 // set users token/secret153 client.OauthCredentials.Token = "TOKEN"154 client.OauthCredentials.Secret = "SECRET"155 results, err := client.GetModels(1)156}157func ExampleClient_GetModelInfo() {158 client := shapeways.NewClient(159 "MY CONSUMER KEY",160 "MY CONSUMER SECRET",161 "http://localhost/callback",162 )163 // set users token/secret164 client.OauthCredentials.Token = "TOKEN"165 client.OauthCredentials.Secret = "SECRET"166 results, err := client.GetModelInfo(1670823)167}168func ExampleClient_GetModelFile() {169 client := shapeways.NewClient(170 "MY CONSUMER KEY",171 "MY CONSUMER SECRET",172 "http://localhost/callback",173 )174 // set users token/secret175 client.OauthCredentials.Token = "TOKEN"176 client.OauthCredentials.Secret = "SECRET"177 // do not include raw file in result178 results, err := client.GetModelFile(1670823, 1, false)179 // include raw file in result180 results, err := client.GetModelFile(1670823, 1, true)181}182func ExampleClient_GetPrice() {183 client := shapeways.NewClient(184 "MY CONSUMER KEY",185 "MY CONSUMER SECRET",186 "http://localhost/callback",187 )188 // set users token/secret189 client.OauthCredentials.Token = "TOKEN"190 client.OauthCredentials.Secret = "SECRET"191 priceData := url.Values{}192 priceData.Set("volume", "0.005")193 priceData.Set("area", "0.05")194 priceData.Set("xBoundMin", "0.1")195 priceData.Set("xBoundMax", "0.5")196 priceData.Set("yBoundMin", "0.1")197 priceData.Set("yBoundMax", "0.5")198 priceData.Set("zBoundMin", "0.1")199 priceData.Set("zBoundMax", "0.5")200 results, err := client.GetPrice(priceData)201}202func ExampleClient_GetPrinters() {203 client := shapeways.NewClient(204 "MY CONSUMER KEY",205 "MY CONSUMER SECRET",206 "http://localhost/callback",207 )208 // set users token/secret209 client.OauthCredentials.Token = "TOKEN"210 client.OauthCredentials.Secret = "SECRET"211 results, err := client.GetPrinters()212}213func ExampleClient_GetPrinter() {214 client := shapeways.NewClient(215 "MY CONSUMER KEY",216 "MY CONSUMER SECRET",217 "http://localhost/callback",218 )219 // set users token/secret220 client.OauthCredentials.Token = "TOKEN"221 client.OauthCredentials.Secret = "SECRET"222 results, err := client.GetPrinter(1)223}...

Full Screen

Full Screen

NewClient

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Enter the string:")4 scanner := bufio.NewScanner(os.Stdin)5 if scanner.Scan() {6 input = scanner.Text()7 }8 secret := NewSecret(input)9 secret.Print()10}11func NewSecret(input string) Secret {12 return Secret(input)13}14func (s Secret) Print() {15 fmt.Println(s)16}

Full Screen

Full Screen

NewClient

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 client := io.NewClient("adafruit_username", "adafruit_key")4 feeds, _, err := client.ListFeeds(0, 100)5 if err != nil {6 fmt.Printf("Error fetching feeds: %s7 }8 for _, feed := range feeds {9 fmt.Printf("%s10 }11}12import (13func main() {14 client := io.NewClient("adafruit_username", "adafruit_key")15 feed, _, err := client.CreateFeed("newfeed")16 if err != nil {17 fmt.Printf("Error creating feed: %s18 }19 fmt.Println(feed.Name)20}21import (22func main() {23 client := io.NewClient("adafruit_username", "adafruit_key")24 feeds, _, err := client.ListFeeds(0, 100)25 if err != nil {26 fmt.Printf("Error fetching feeds: %s27 }28 for _, feed := range feeds {29 fmt.Printf("%s30 }31}32import (33func main() {34 client := io.NewClient("adafruit_username", "adafruit_key")35 feeds, _, err := client.ListFeeds(0, 100)36 if err != nil {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testkube automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful