This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from datasift/sep2015updates
Added support for ODP ingestion - DEV-3592
- Loading branch information
Showing
13 changed files
with
301 additions
and
10 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
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
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,14 @@ | ||
using RestSharp; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DataSift.Rest | ||
{ | ||
public interface IIngestAPIRequest | ||
{ | ||
RestAPIResponse Ingest(string endpoint, dynamic data, Method method = Method.POST); | ||
} | ||
} |
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,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Contracts; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DataSift.Rest | ||
{ | ||
public class ODP | ||
{ | ||
DataSiftClient _client = null; | ||
|
||
internal ODP(DataSiftClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
public RestAPIResponse Ingest(string sourceId, dynamic data) | ||
{ | ||
Contract.Requires<ArgumentNullException>(sourceId != null); | ||
Contract.Requires<ArgumentException>(sourceId.Trim().Length > 0); | ||
Contract.Requires<ArgumentException>((sourceId != null) ? Constants.SOURCE_ID_FORMAT.IsMatch(sourceId) : true, Messages.INVALID_SOURCE_ID); | ||
|
||
if (data == null) | ||
throw new ArgumentNullException("data", "data parameter cannot be null"); | ||
|
||
if (!(data.GetType().IsArray)) | ||
throw new ArgumentException("data", "data parameter must be an array of objects"); | ||
|
||
return _client.GetIngestRequest().Ingest(sourceId, data); | ||
} | ||
} | ||
} |
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
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 @@ | ||
using DataSift; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DataSiftExamples | ||
{ | ||
static class Ingestion | ||
{ | ||
internal static void Run(string username, string apikey) | ||
{ | ||
var client = new DataSiftClient(username, apikey); | ||
|
||
Console.WriteLine("Running 'Ingestion' example..."); | ||
|
||
var response = client.ODP.Ingest("d44757b030a1499492f539591d86fe3e", new[] { | ||
new { | ||
title = "Dummy content" | ||
} | ||
}); | ||
|
||
Console.WriteLine("\nIngestion response: " + JsonConvert.SerializeObject(response.Data)); | ||
|
||
} | ||
} | ||
} |
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
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
Oops, something went wrong.