Code Monkey home page Code Monkey logo

connect_sdk_csharp's Introduction

Connect SDK - C#

Introduction

This SDK makes using the Getty Images Connect API easy. It handles credential management, makes HTTP requests and is written with a fluent style in mind. The Connect API Documentation is located on Github.

What's provided?

This Solution contains two projects:

  • ConnectSdk - the SDK library.
  • ConnectSdk.OnlineTests - tests for the SDK library.

Tests

The Connect team at Getty Images uses Behavior Driven Development (BDD). We think it's a great way to develop software and want to spread the word. The test project contains scenarios written in the Gherkin language which are bound to code using SpecFlow.

Getting started

From Source Code

Assumptions

  • You have Visual Studio 2013 - this solution should work with 2012, but it has not been tested.
  • You have Git installed
  • You have the SpecFlow extension installed in Visual Studio

Clone the repository

The Git repository contains a submodule which requires some special handling to get setup properly. This is because we share our scenario files across all our SDKs.

Open a console window (Command Prompt, PowerShell or Bash) and issue the following commands to clone the Git repository:

git clone [email protected]:gettyimages/connect_sdk_csharp.git
pushd connect_sdk_csharp
git submodule update --init

Build using Command Prompt or Powershell

.\build.cmd

Build using Bash

./build.sh

If you just want to start using the SDK, jump down to Using the Nuget Package

Opening the code in Visual Studio and running tests

Setup environment variables

The tests expect credentials to be stored in environment variables.

  • ConnectSDK_ApiKey: API key assigned when you registered
  • ConnectSDK_ApiSecret: API secret assigned when you registered
  • ConnectSDK_UserName: a Getty Images user. Create one at the Getty Images website.
  • ConnectSDK_UserPassword: Getty Images user's password

Note: If you don't have user account credentials, some of the tests will fail. That's OK!

Once this is complete, you can open the solution in Visual Studio:

  1. Open the ConnectSdk.sln file.
  2. Build the solution.
  3. Tests can be run using:

Using the Nuget Package

The SDK will be published to the public Nuget package repository soon. Keep an eye out for it! When you run the build from the command line, a Nuget package is built. You can reference this package from your project.

Add a new package source in Visual Studio, pointing to the directory you cloned to: Adding a new package source

Open the package manager and add the package to your project: Add nuget package reference

Usage

The SDK currently supports:

  • Searching for images
  • Getting image metadata
  • Creating download URLs

Code

The SDK supports async operations, however it can also be used synchonously, such as when running in a console application:

var connect = ConnectSdk.GetConnectSdkWithClientCredentials("my_api_key", "my_api_secret");
var searchResult = connect.Search()
    .Images()
    .Editorial()
    .WithEditorialSegment(EditorialSegment.News)
    .WithPhrase("all vocabulary")
    .WithSortOrder("newest")
    .ExecuteAsync()
    .Result;

foreach (var image in searchResult.images)
{
    Console.WriteLine("Title: {0} \r\nId: {1}", image.title, image.id);
}

Results are returned as dynamic. Visit the Connect API Interactive Documentation to learn more about available parameters and to see what the response object look like.

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.