Giter Site home page Giter Site logo

spaytac / commercial-marketplace-client-dotnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/commercial-marketplace-client-dotnet

0.0 0.0 0.0 383 KB

The Microsoft Commercial Marketplace SaaS .NET client enables publishers to build solutions interacting with Fulfillment and Metering APIs with .NET.

License: MIT License

C# 99.94% Batchfile 0.06%

commercial-marketplace-client-dotnet's Introduction

.NET Core

Change log

- Started using AutoRest C# generator V3 to take advantage of new features.
- Removed container based code generation. Using the code build target for code generation coming with C# generator V3. Please see the generate.cmd file in the src folder.
- Modified the repo structure for streamlining with the new code generation method.
- Added two C# projects supporting code generation (SaaS and Metering) and one project for building the binary assets (Microsoft.Marketplace.csproj).    

Breaking changes for preview2

- Constructors for the clients are now using classes deriving from Azure.Core.TokenCredential defined in Azure.Identity namespace (in Azure.Identity NuGet package)
- Removed *TokenProvider 
- Removed ListAllSubscriptionsAsync method on the FulfillmentOperations in favor of the generated ListSubscriptions* methods that implement pagination. Please see the tests for different usages.
- Renamed FulfillmentOperations property on the MarketplaceSaaSClient to Fulfillment
- Removed serialization checks on the SubscriberPlan and UsageEvent classes for consistency. The libraries rely on serialization checks on the service side.

Using the client libraries

The library has two clients, one for the SaaS fulfillment API version 2 (MarketplaceSaaSClient) and one for metered billing APIs (MarketplaceMeteringClient).

Both of them use the client credentials flow, service-to-service authentication for authenticating to call the APIs. The clients support both client secrets and X.509 certificates.After registering an single-tenant application on Azure AD, just create a client secret, or use a X.509 to call the constructor as follows:

    new MarketplaceSaaSClient(new ClientSecretCredential(config["TenantId"], config["ClientId"], config["clientSecret"]));

If you want to use an X.509 certificate instead, use ClientCertificateCredential where clientCertificate is of type System*.Security.Cryptography.X509Certificates.X509Certificate2.

        new MarketplaceSaaSClient(new ClientCertificateCredential (config["TenantId"], config["ClientId"], clientCertificate);

Then call the appropriate method corresponding to the API call.

    var subscriptions = await this.sut.Fulfillment.ListSubscriptionsAsync().ToListAsync();

Running the tests

We are using the Azure.Core.TestFramework from the Azure SDK for .NET. Since no NuGet package includes this assembly at the time of the development of this library project, we opted to make a copy of that source tree and directly include in our repository.

We will be turning on the RecordedTestMode.Record each time we generate the client code when the API surface changes or we need to change the implementation. We are including the session recordings, and the tests will be run against the recorded sessions by default.

The tests use the standard .NET core configuration system user secrets for configuration. Simply add user secrets for the following values, using your favorite method, i.e. either "dotnet user-secrets", Visual Studio Code extension, or Visual Studio 2019 user secrets menu option.

  • TenantId
  • ClientId
  • clientSecret

If you want to record your own sessions, turn on recording by modifying the test constructor and use RecordedTestMode.Record, then run the tests.

One test requires a marketplace purchase identification token and you can get it from a landing page link generated from an actual subscription. Simply url-decode it, and set the value in the test.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

commercial-marketplace-client-dotnet's People

Contributors

code4clouds avatar dstarr avatar ercenk avatar microsoftopensource avatar scseely avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.