{"action":"created","comment":{"url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments/46676132","id":46676132,"diff_hunk":"@@ -0,0 +1,332 @@\n+package net.pubnative.library.request;\n+\n+import android.content.Context;\n+import android.location.Location;\n+import android.net.Uri;\n+import android.os.Build;\n+import android.support.annotation.NonNull;\n+import android.text.TextUtils;\n+import android.util.DisplayMetrics;\n+\n+import com.android.volley.Request;\n+import com.android.volley.RequestQueue;\n+import com.android.volley.Response;\n+import com.android.volley.VolleyError;\n+import com.android.volley.toolbox.StringRequest;\n+import com.android.volley.toolbox.Volley;\n+import com.google.gson.Gson;\n+import com.google.gson.reflect.TypeToken;\n+\n+import net.pubnative.library.models.PubnativeAdModel;\n+import net.pubnative.library.utils.Crypto;\n+import net.pubnative.library.utils.SystemUtils;\n+\n+import org.json.JSONArray;\n+import org.json.JSONException;\n+import org.json.JSONObject;\n+\n+import java.lang.reflect.Type;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Locale;\n+import java.util.Map;\n+\n+/**\n+ * For every Ad request create new object of this class\n+ */\n+public class PubnativeRequest implements SystemUtils.AndroidAdIdTask.AndroidAdIdListener, Response.Listener<String>, Response.ErrorListener {\n+    private static final String   BASE_URL        =  \"http://api.pubnative.net/api/partner/v2/promotions\";\n+    private static final String   NATIVE_TYPE_URL =  \"native\";\n+    protected Context             context;\n+    protected EndPoint            endpoint;\n+    protected Map<String, String> requestParameters;\n+    protected Listener            listener;\n+\n+    /**\n+     * These are the various types of adds pubnative support\n+     */\n+    public enum EndPoint {\n+        NATIVE\n+    }\n+\n+    /**\n+     * These are the various types of parameters\n+     */\n+    public interface Parameters {\n+        String APP_TOKEN                  =      \"app_token\";\n+        String BUNDLE_ID                  =      \"bundle_id\";\n+        String APPLE_IDFA                 =      \"apple_idfa\";\n+        String APPLE_IDFA_SHA1            =      \"apple_idfa_sha1\";\n+        String APPLE_IDFA_MD5             =      \"apple_idfa_md5\";\n+        String ANDROID_ADVERTISER_ID      =      \"android_advertiser_id\";\n+        String ANDROID_ADVERTISER_ID_SHA1 =      \"android_advertiser_id_sha1\";\n+        String ANDROID_ADVERTISER_ID_MD5  =      \"android_advertiser_id_md5\";\n+        String ICON_SIZE                  =      \"icon_size\";\n+        String BANNER_SIZE                =      \"banner_size\";\n+        String OS                         =      \"os\";\n+        String DEVICE_MODEL               =      \"device_model\";\n+        String OS_VERSION                 =      \"os_version\";\n+        String NO_USER_ID                 =      \"no_user_id\";\n+        String PARTNER                    =      \"partner\";\n+        String LOCALE                     =      \"locale\";\n+        String PORTRAIT_BANNER_SIZE       =      \"portrait_banner_size\";\n+        String DEVICE_RESOLUTION          =      \"device_resolution\";\n+        String DEVICE_TYPE                =      \"device_type\";\n+        String AD_COUNT                   =      \"ad_count\";\n+        String ZONE_ID                    =      \"zone_id\";\n+        String LAT                        =      \"lat\";\n+        String LONG                       =      \"long\";\n+        String GENDER                     =      \"gender\";\n+        String AGE                        =      \"age\";\n+        String KEYWORDS                   =      \"keywords\";\n+    }\n+\n+    /**\n+     * Listener interface used to start Pubnative request with success and failure callbacks.\n+     */\n+    public interface Listener {\n+        /**\n+         * Invoked when PubnativeRequest request is success\n+         *\n+         * @param request Request object used for making the request\n+         * @param ads     List of ads received\n+         */\n+        void onPubnativeRequestSuccess(PubnativeRequest request, List<PubnativeAdModel> ads);\n+\n+        /**\n+         * Invoked when PubnativeRequest request fails\n+         *\n+         * @param request Request object used for making the request\n+         * @param ex      Exception that caused the failure\n+         */\n+        void onPubnativeRequestFail(PubnativeRequest request, Exception ex);\n+    }\n+\n+    /**\n+     * Sets parameters required to make the pub native request\n+     *\n+     * @param key key name of parameter\n+     * @param value actual value of parameter\n+     */\n+    public void setParameter(String key, String value) {\n+        if (requestParameters == null) {\n+            requestParameters = new HashMap<String, String>();\n+        }\n+        if (value == null || TextUtils.isEmpty(value)) {","path":"library/src/main/java/net/pubnative/library/request/PubnativeRequest.java","position":115,"original_position":115,"commit_id":"e0fb5529926df70d0c1fe259837a402ca56a22e1","original_commit_id":"e0fb5529926df70d0c1fe259837a402ca56a22e1","user":{"login":"cerberillo","id":422329,"avatar_url":"https://avatars.githubusercontent.com/u/422329?v=3","gravatar_id":"","url":"https://api.github.com/users/cerberillo","html_url":"https://github.com/cerberillo","followers_url":"https://api.github.com/users/cerberillo/followers","following_url":"https://api.github.com/users/cerberillo/following{/other_user}","gists_url":"https://api.github.com/users/cerberillo/gists{/gist_id}","starred_url":"https://api.github.com/users/cerberillo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cerberillo/subscriptions","organizations_url":"https://api.github.com/users/cerberillo/orgs","repos_url":"https://api.github.com/users/cerberillo/repos","events_url":"https://api.github.com/users/cerberillo/events{/privacy}","received_events_url":"https://api.github.com/users/cerberillo/received_events","type":"User","site_admin":false},"body":"You should also check the key nullity and emptiness  before doing nothing with It","created_at":"2015-12-04T12:16:09Z","updated_at":"2015-12-04T12:16:09Z","html_url":"https://github.com/pubnative/pubnative-android-library/pull/43#discussion_r46676132","pull_request_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments/46676132"},"html":{"href":"https://github.com/pubnative/pubnative-android-library/pull/43#discussion_r46676132"},"pull_request":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43","id":52529006,"html_url":"https://github.com/pubnative/pubnative-android-library/pull/43","diff_url":"https://github.com/pubnative/pubnative-android-library/pull/43.diff","patch_url":"https://github.com/pubnative/pubnative-android-library/pull/43.patch","issue_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/43","number":43,"state":"open","locked":false,"title":"Pubnative request","user":{"login":"gauravmehta19","id":15997842,"avatar_url":"https://avatars.githubusercontent.com/u/15997842?v=3","gravatar_id":"","url":"https://api.github.com/users/gauravmehta19","html_url":"https://github.com/gauravmehta19","followers_url":"https://api.github.com/users/gauravmehta19/followers","following_url":"https://api.github.com/users/gauravmehta19/following{/other_user}","gists_url":"https://api.github.com/users/gauravmehta19/gists{/gist_id}","starred_url":"https://api.github.com/users/gauravmehta19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gauravmehta19/subscriptions","organizations_url":"https://api.github.com/users/gauravmehta19/orgs","repos_url":"https://api.github.com/users/gauravmehta19/repos","events_url":"https://api.github.com/users/gauravmehta19/events{/privacy}","received_events_url":"https://api.github.com/users/gauravmehta19/received_events","type":"User","site_admin":false},"body":"PubnativeRequest with its test cases","created_at":"2015-12-03T12:40:13Z","updated_at":"2015-12-04T12:16:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"030519e4be82981b19b4453d652eed10f0fbf42a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43/commits","review_comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43/comments","review_comment_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/43/comments","statuses_url":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/e0fb5529926df70d0c1fe259837a402ca56a22e1","head":{"label":"pubnative:PubnativeRequest","ref":"PubnativeRequest","sha":"e0fb5529926df70d0c1fe259837a402ca56a22e1","user":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"repo":{"id":28917789,"name":"pubnative-android-library","full_name":"pubnative/pubnative-android-library","owner":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pubnative/pubnative-android-library","description":"","fork":false,"url":"https://api.github.com/repos/pubnative/pubnative-android-library","forks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/forks","keys_url":"https://api.github.com/repos/pubnative/pubnative-android-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pubnative/pubnative-android-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pubnative/pubnative-android-library/teams","hooks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/hooks","issue_events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/events{/number}","events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/events","assignees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/assignees{/user}","branches_url":"https://api.github.com/repos/pubnative/pubnative-android-library/branches{/branch}","tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/tags","blobs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/{sha}","languages_url":"https://api.github.com/repos/pubnative/pubnative-android-library/languages","stargazers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/stargazers","contributors_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contributors","subscribers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscribers","subscription_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscription","commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contents/{+path}","compare_url":"https://api.github.com/repos/pubnative/pubnative-android-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pubnative/pubnative-android-library/merges","archive_url":"https://api.github.com/repos/pubnative/pubnative-android-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pubnative/pubnative-android-library/downloads","issues_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues{/number}","pulls_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls{/number}","milestones_url":"https://api.github.com/repos/pubnative/pubnative-android-library/milestones{/number}","notifications_url":"https://api.github.com/repos/pubnative/pubnative-android-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pubnative/pubnative-android-library/labels{/name}","releases_url":"https://api.github.com/repos/pubnative/pubnative-android-library/releases{/id}","created_at":"2015-01-07T14:26:18Z","updated_at":"2015-10-06T09:01:03Z","pushed_at":"2015-12-04T10:04:31Z","git_url":"git://github.com/pubnative/pubnative-android-library.git","ssh_url":"git@github.com:pubnative/pubnative-android-library.git","clone_url":"https://github.com/pubnative/pubnative-android-library.git","svn_url":"https://github.com/pubnative/pubnative-android-library","homepage":null,"size":2769,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":5,"default_branch":"master"}},"base":{"label":"pubnative:development","ref":"development","sha":"df62495961b9ebe8eb6fa57996e835a3fb76b80b","user":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"repo":{"id":28917789,"name":"pubnative-android-library","full_name":"pubnative/pubnative-android-library","owner":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pubnative/pubnative-android-library","description":"","fork":false,"url":"https://api.github.com/repos/pubnative/pubnative-android-library","forks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/forks","keys_url":"https://api.github.com/repos/pubnative/pubnative-android-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pubnative/pubnative-android-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pubnative/pubnative-android-library/teams","hooks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/hooks","issue_events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/events{/number}","events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/events","assignees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/assignees{/user}","branches_url":"https://api.github.com/repos/pubnative/pubnative-android-library/branches{/branch}","tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/tags","blobs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/{sha}","languages_url":"https://api.github.com/repos/pubnative/pubnative-android-library/languages","stargazers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/stargazers","contributors_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contributors","subscribers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscribers","subscription_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscription","commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contents/{+path}","compare_url":"https://api.github.com/repos/pubnative/pubnative-android-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pubnative/pubnative-android-library/merges","archive_url":"https://api.github.com/repos/pubnative/pubnative-android-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pubnative/pubnative-android-library/downloads","issues_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues{/number}","pulls_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls{/number}","milestones_url":"https://api.github.com/repos/pubnative/pubnative-android-library/milestones{/number}","notifications_url":"https://api.github.com/repos/pubnative/pubnative-android-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pubnative/pubnative-android-library/labels{/name}","releases_url":"https://api.github.com/repos/pubnative/pubnative-android-library/releases{/id}","created_at":"2015-01-07T14:26:18Z","updated_at":"2015-10-06T09:01:03Z","pushed_at":"2015-12-04T10:04:31Z","git_url":"git://github.com/pubnative/pubnative-android-library.git","ssh_url":"git@github.com:pubnative/pubnative-android-library.git","clone_url":"https://github.com/pubnative/pubnative-android-library.git","svn_url":"https://github.com/pubnative/pubnative-android-library","homepage":null,"size":2769,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43"},"html":{"href":"https://github.com/pubnative/pubnative-android-library/pull/43"},"issue":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/43"},"comments":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/e0fb5529926df70d0c1fe259837a402ca56a22e1"}}}}