linkshare-oauth2-api 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c9e4c11a42fb786f0278c60e881e04481aec6cf
4
- data.tar.gz: 2c415a5b8fa3636a1d73e52a7b798fd161a5c03a
3
+ metadata.gz: 83fc73fc45f02f459b6f0bf9278c483aae7eea76
4
+ data.tar.gz: 33078867327c670a50ae323400d54c89681d174a
5
5
  SHA512:
6
- metadata.gz: 1555242669007040e4827161935e3628b6620044ad2fd3e3ff8ceb382d5e6758f3d679d8f971fde9cfe38f34eec2685826b7cb4572aa8e602abed3e33c65d1b5
7
- data.tar.gz: 385ecbed5eb1e49d1e6f08cb1a09c39c670d02f3dd3a8b6bc1b61501c7edb2ecda05be10bd85f5fe4836911e569813e67a2c4f2c41eea0dc32c1197b96707939
6
+ metadata.gz: e0975a6103cf2e07bc9f5c92c236bfea010d6c8d8a9681dc8980efa888e11756b7d6c59a128cb7d069a4024236062b0f8d9ed64ea4463ccec027558dbb67b024
7
+ data.tar.gz: c828007bf369e654f733b6f2ad88079fec8821514313806d081631011cc3ac0643bc9767d33f946817f1ed8a34243345494997a6b1087fd2680744aba4459ee8
@@ -7,6 +7,7 @@ require 'linkshare/strategy'
7
7
  require 'linkshare/coupon'
8
8
  require 'linkshare/link_locator'
9
9
  require 'linkshare/advanced_reports'
10
+ require 'linkshare/custom_reports'
10
11
  require 'linkshare/product_search'
11
12
  require 'linkshare/events'
12
13
  require 'linkshare/advertiser_search'
@@ -15,6 +16,7 @@ module Linkshare
15
16
  coupon: "https://api.rakutenmarketing.com/coupon/1.0",
16
17
  link_locator: "https://api.rakutenmarketing.com/linklocator/1.0",
17
18
  advanced_reports: "https://api.rakutenmarketing.com/advancedreports/1.0",
19
+ custom_reports: "https://ran-reporting.rakutenmarketing.com/en/reports",
18
20
  product_search: "https://api.rakutenmarketing.com/productsearch/1.0",
19
21
  events: "https://api.rakutenmarketing.com/events/1.0/transactions",
20
22
  advertiser_search: "https://api.rakutenmarketing.com/advertisersearch/1.0"
@@ -23,7 +25,7 @@ module Linkshare
23
25
  TOKEN_URL = "token/"
24
26
 
25
27
  class << self
26
- attr_accessor :consumer_key, :consumer_secret, :sid, :username, :password, :security_token
28
+ attr_accessor :consumer_key, :consumer_secret, :sid, :username, :password, :security_token, :custom_report_token
27
29
  end
28
30
 
29
31
  def self.token
@@ -46,6 +48,10 @@ module Linkshare
46
48
  @advancedreports ||= Linkshare::AdvancedReports.new
47
49
  end
48
50
 
51
+ def self.customreports
52
+ @customreports ||= Linkshare::CustomReports.new
53
+ end
54
+
49
55
  def self.advertisersearch
50
56
  @advertisersearch ||= Linkshare::AdvertiserSearch.new
51
57
  end
@@ -0,0 +1,38 @@
1
+ require "open-uri"
2
+ module Linkshare
3
+ class CustomReports
4
+ def initilize()
5
+ @reportsCSV = ''
6
+ @reportsRows = []
7
+ @cols = []
8
+ end
9
+ def getCSV
10
+ @reportsCSV
11
+ end
12
+
13
+ def getReports
14
+ @reportsRows
15
+ end
16
+ def fetchReports(reportname, bdate, edate, network, tz="America%2FNew_York", date_type='transaction', include_summary="N")
17
+ token = Linkshare.custom_report_token
18
+ url = Linkshare::API_URIS[:custom_reports]+'/'+reportname+'/filters?start_date='+bdate+'&end_date='+edate+'&include_summary='+include_summary+'&network='+network.to_s+'&tz='+tz+'&date_type='+date_type+'&token='+token
19
+ @reportsRows = []
20
+ @reportsCSV = open(url).read()
21
+ reportsrows = @reportsCSV.force_encoding("UTF-8").gsub("\"",'').split(/\n/)
22
+ if reportsrows[1].match(/^\{code\:.*\}$/)
23
+ raise 'Linkshare Error (custom report): ' + reportsrows[1]
24
+ end
25
+ @cols = reportsrows[0].split(/,/)
26
+ reportsrows.shift
27
+ reportsrows.each { |row|
28
+ r = {}
29
+ split_row = row.split(/,/)
30
+ @cols.each_with_index { | o, i|
31
+ r[@cols[i]]=split_row[i]
32
+ }
33
+ @reportsRows.push(r)
34
+ }
35
+ @reportsRows
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Linkshare
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linkshare-oauth2-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rudie Shahinian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -67,6 +67,7 @@ files:
67
67
  - lib/linkshare/advanced_reports.rb
68
68
  - lib/linkshare/advertiser_search.rb
69
69
  - lib/linkshare/coupon.rb
70
+ - lib/linkshare/custom_reports.rb
70
71
  - lib/linkshare/events.rb
71
72
  - lib/linkshare/link_locator.rb
72
73
  - lib/linkshare/product_search.rb