Skip to content

Commit

Permalink
refac: created requestObject
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Dec 19, 2015
1 parent 15b8cd4 commit 43eb419
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Jonathan Hornung <[email protected]>"
],
"version": "0.1.10",
"version": "0.1.11",
"description": "twitter plugin for apiNG",
"main": "dist/apiNG-plugin-codebird.min.js",
"moduleType": [],
Expand Down
1 change: 1 addition & 0 deletions demo/aping-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ apingApp.config(['$provide', function ($provide) {
orderBy : "timestamp",
orderReverse : "true",
model: "social",
getNativeData: false,
});

}]);
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</head>
<body ng-app="app">
<h1>{'search':'münchen', 'result_type':'recent', 'language':'de'}</h1>
<aping model="social" items="20" aping-codebird="[{'search':'münchen', 'result_type':'recent', 'language':'de'}]"></aping>
<aping model="social" aping-codebird="[{'search':'münchen', 'result_type':'recent', 'language':'de'}]"></aping>
<hr>
<h1>{'search':'münchen', 'result_type':'recent', 'lat':'48.1374300', 'lng':'11.5754900', 'distance':5}</h1>
<aping model="social" aping-codebird="[{'search':'münchen', 'result_type':'recent', 'lat':'48.1374300', 'lng':'11.5754900', 'distance':5}]"></aping>
Expand Down
4 changes: 2 additions & 2 deletions dist/aping-plugin-codebird.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aping-plugin-codebird",
"version": "0.1.10",
"version": "0.1.11",
"description": "twitter plugin for apiNG",
"main": "Gruntfile.js",
"scripts": {
Expand Down
32 changes: 20 additions & 12 deletions src/aping-codebird-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,36 @@ var jjtApingCodebird = angular.module("jtt_aping_codebird", [])
helperObject.getNativeData = false;
}

//create requestObject for api request call
var requestObject = {};
if(typeof request.items !== "undefined") {
requestObject.count = request.items;
} else {
requestObject.count = appSettings.items;
}

if(request.search) {
requestObject.q = request.search;
requestObject.result_type = request.result_type || "mixed";

//https://dev.twitter.com/rest/reference/get/search/tweets
var params = {
var requestObject = {
q: request.search,
result_type: request.result_type || "mixed",
count:request.items || appSettings.items,
};

if(typeof request.lat !== "undefined" && typeof request.lng !== "undefined") {
params.geocode = request.lat+","+request.lng+","+(request.distance || "1" )+"km";
requestObject.geocode = request.lat+","+request.lng+","+(request.distance || "1" )+"km";
}

if(typeof request.language !== "undefined") {
params.lang = request.language;
requestObject.lang = request.language;
}

cb.__call(
"search_tweets",
params,
requestObject,
function (_data) {
apingController.concatToResults(apingCodebirdHelper.getObjectByJsonData(_data, helperObject));
apingController.apply();
Expand All @@ -64,23 +74,21 @@ var jjtApingCodebird = angular.module("jtt_aping_codebird", [])

} else if(request.user) {
//https://dev.twitter.com/rest/reference/get/statuses/user_timeline
var params = {
screen_name: request.user,
contributor_details: true,
count: request.items || appSettings.items
};

requestObject.screen_name = request.user;
requestObject.contributor_details = true;

if(request.exclude_replies === true || request.exclude_replies === "true"){
params.exclude_replies = true;
requestObject.exclude_replies = true;
}

if(request.include_rts === false || request.include_rts === "false"){
params.include_rts = false;
requestObject.include_rts = false;
}

cb.__call(
"statuses_userTimeline",
params,
requestObject,
function (_data, rate, err) {
apingController.concatToResults(apingCodebirdHelper.getObjectByJsonData(_data, helperObject));
apingController.apply();
Expand Down

0 comments on commit 43eb419

Please sign in to comment.