yandex-api-direct 0.0.1
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.
- data/.document +5 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +163 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/lib/yandex-api-direct.rb +69 -0
- data/lib/yandex-api-direct/yandex_object.rb +131 -0
- data/lib/yandex-api-direct/yandex_objects/campaign.rb +39 -0
- data/lib/yandex-api-direct/yandex_objects/campaign_param.rb +17 -0
- data/lib/yandex-api-direct/yandex_objects/campaign_stats.rb +25 -0
- data/lib/yandex-api-direct/yandex_objects/client.rb +38 -0
- data/lib/yandex-api-direct/yandex_objects/generic.rb +23 -0
- data/test/fixtures/yandex_campaign_params.json +103 -0
- data/test/fixtures/yandex_campaign_stats.json +52 -0
- data/test/fixtures/yandex_get_campaigns_list.json +61 -0
- data/test/fixtures/yandex_get_client_info.json +18 -0
- data/test/fixtures/yandex_get_client_list.json +34 -0
- data/test/fixtures/yandex_object_valid_responce.json +15 -0
- data/test/models.rb +5 -0
- data/test/test_helper.rb +50 -0
- data/test/test_yandex-api.rb +36 -0
- data/test/yandex-api-direct/test_campaign.rb +68 -0
- data/test/yandex-api-direct/test_campaign_params.rb +32 -0
- data/test/yandex-api-direct/test_campaign_stats.rb +35 -0
- data/test/yandex-api-direct/test_client.rb +113 -0
- data/test/yandex-api-direct/test_generic.rb +47 -0
- data/test/yandex-api-direct/test_yandex_object.rb +131 -0
- metadata +233 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module YandexApiDirect
|
6
|
+
class Campaign < Hashr
|
7
|
+
|
8
|
+
include YandexObject
|
9
|
+
extend YandexObject
|
10
|
+
|
11
|
+
#perform find call
|
12
|
+
def self.find params = {}
|
13
|
+
call_method("get_campaigns_list", params)[:data].collect do |campaign_args|
|
14
|
+
new campaign_args
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#get params for campaign
|
19
|
+
# input args:
|
20
|
+
# {
|
21
|
+
# start_date: Date
|
22
|
+
# end_date: Date
|
23
|
+
# }
|
24
|
+
def campaign_params
|
25
|
+
CampaignParams.find campaign_ids: [campaign_id]
|
26
|
+
end
|
27
|
+
|
28
|
+
#get stats for campaign
|
29
|
+
# input args:
|
30
|
+
# {
|
31
|
+
# start_date: Date
|
32
|
+
# end_date: Date
|
33
|
+
# }
|
34
|
+
def campaign_stats args
|
35
|
+
CampaignStats.find args.merge(campaign_ids: [campaign_id])
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module YandexApiDirect
|
6
|
+
class CampaignParams < Hashr
|
7
|
+
|
8
|
+
include YandexObject
|
9
|
+
extend YandexObject
|
10
|
+
|
11
|
+
#perform find call
|
12
|
+
def self.find params = {}
|
13
|
+
new call_method("get_campaign_params", camelize_keys(params))[:data]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module YandexApiDirect
|
6
|
+
class CampaignStats < Hashr
|
7
|
+
|
8
|
+
include YandexObject
|
9
|
+
extend YandexObject
|
10
|
+
|
11
|
+
#get stats for campaign
|
12
|
+
# input args:
|
13
|
+
# {
|
14
|
+
# campaign_ids: [Integer]
|
15
|
+
# start_date: Date
|
16
|
+
# end_date: Date
|
17
|
+
# }
|
18
|
+
def self.find params = {}
|
19
|
+
call_method("get_summary_stat", camelize_keys(params))[:data].collect do |stats_data|
|
20
|
+
new stats_data
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module YandexApiDirect
|
6
|
+
class Client < Hashr
|
7
|
+
|
8
|
+
include YandexObject
|
9
|
+
extend YandexObject
|
10
|
+
|
11
|
+
#perform find call
|
12
|
+
def self.find params = {}
|
13
|
+
call_method("get_clients_list", params)[:data].collect do |client_args|
|
14
|
+
new client_args
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# get campaigns by client
|
19
|
+
def campaigns
|
20
|
+
call_method("get_campaigns_list", [login])[:data].collect do |campaign_args|
|
21
|
+
Campaign.new campaign_args
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# get campaign stats for client by campaigns
|
26
|
+
# input args:
|
27
|
+
# {
|
28
|
+
# start_date: Date
|
29
|
+
# end_date: Date
|
30
|
+
# }
|
31
|
+
def campaigns_stats args
|
32
|
+
campaigns.collect do |campaign|
|
33
|
+
campaign.stats = campaign.campaign_stats(args.merge(campaign_ids: [campaign.campaign_id])).select{|s| s.campaign_id == campaign.campaign_id}
|
34
|
+
campaign
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module YandexApiDirect
|
6
|
+
class Generic < Hashr
|
7
|
+
|
8
|
+
include YandexObject
|
9
|
+
extend YandexObject
|
10
|
+
|
11
|
+
# get custom method response
|
12
|
+
def self.get method_name, args = nil
|
13
|
+
data = call_method(method_name, camelize_keys(args))[:data]
|
14
|
+
if data.is_a?(Array)
|
15
|
+
data.collect do |generic_data|
|
16
|
+
new generic_data
|
17
|
+
end
|
18
|
+
else
|
19
|
+
new data
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
{
|
2
|
+
"data": {
|
3
|
+
"ContextLimitSum": null,
|
4
|
+
"Status": "This campaign has been stopped",
|
5
|
+
"DisabledDomains": null,
|
6
|
+
"IsActive": "No",
|
7
|
+
"Login": "login",
|
8
|
+
"Strategy": {
|
9
|
+
"AveragePrice": null,
|
10
|
+
"StrategyName": "WeeklyBudget",
|
11
|
+
"MaxPrice": 0.12,
|
12
|
+
"WeeklySumLimit": 18,
|
13
|
+
"ClicksPerWeek": null
|
14
|
+
},
|
15
|
+
"AddRelevantPhrases": "No",
|
16
|
+
"TimeTarget": {
|
17
|
+
"TimeZone": "Europe/Moscow",
|
18
|
+
"DaysHours": [
|
19
|
+
{
|
20
|
+
"Hours": [
|
21
|
+
0,
|
22
|
+
1,
|
23
|
+
2,
|
24
|
+
3,
|
25
|
+
4,
|
26
|
+
5,
|
27
|
+
6,
|
28
|
+
7,
|
29
|
+
8,
|
30
|
+
9,
|
31
|
+
10,
|
32
|
+
11,
|
33
|
+
12,
|
34
|
+
13,
|
35
|
+
14,
|
36
|
+
15,
|
37
|
+
16,
|
38
|
+
17,
|
39
|
+
18,
|
40
|
+
19,
|
41
|
+
20,
|
42
|
+
21,
|
43
|
+
22,
|
44
|
+
23
|
45
|
+
],
|
46
|
+
"Days": [
|
47
|
+
1,
|
48
|
+
2,
|
49
|
+
3,
|
50
|
+
4,
|
51
|
+
5,
|
52
|
+
6,
|
53
|
+
7
|
54
|
+
]
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"ShowOnHolidays": "Yes"
|
58
|
+
},
|
59
|
+
"StatusShow": "No",
|
60
|
+
"Sum": 40,
|
61
|
+
"StatusMetricaControl": "No",
|
62
|
+
"DisabledIps": null,
|
63
|
+
"AutoOptimization": "Yes",
|
64
|
+
"ManagerName": null,
|
65
|
+
"StatusActivating": "Yes",
|
66
|
+
"StatusContextStop": "No",
|
67
|
+
"AgencyName": null,
|
68
|
+
"ContextPricePercent": 100,
|
69
|
+
"RelevantPhrasesBudgetLimit": 100,
|
70
|
+
"Rest": 36.71,
|
71
|
+
"EmailNotification": {
|
72
|
+
"MoneyWarningValue": 20,
|
73
|
+
"SendAccNews": "Yes",
|
74
|
+
"WarnPlaceInterval": 60,
|
75
|
+
"SendWarn": "Yes",
|
76
|
+
"Email": "fridmanova@ataxo.com"
|
77
|
+
},
|
78
|
+
"StatusBehavior": "Yes",
|
79
|
+
"StatusArchive": "No",
|
80
|
+
"MinusKeywords": [
|
81
|
+
|
82
|
+
],
|
83
|
+
"StatusOpenStat": "No",
|
84
|
+
"CampaignID": 123451,
|
85
|
+
"StartDate": "2008-12-16",
|
86
|
+
"ContextLimit": "Default",
|
87
|
+
"StatusModerate": "Yes",
|
88
|
+
"Clicks": 252,
|
89
|
+
"FIO": "Account name",
|
90
|
+
"Shows": 124343,
|
91
|
+
"ConsiderTimeTarget": "No",
|
92
|
+
"SumAvailableForTransfer": 23.71,
|
93
|
+
"SmsNotification": {
|
94
|
+
"MoneyInSms": "No",
|
95
|
+
"SmsTimeTo": "21:00",
|
96
|
+
"MoneyOutSms": "No",
|
97
|
+
"ModerateResultSms": "No",
|
98
|
+
"SmsTimeFrom": "09:00",
|
99
|
+
"MetricaSms": "No"
|
100
|
+
},
|
101
|
+
"Name": "Campaign #1"
|
102
|
+
}
|
103
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"ClicksSearch": "1",
|
5
|
+
"SumSearch": "0",
|
6
|
+
"SessionDepthSearch": null,
|
7
|
+
"SessionDepthContext": null,
|
8
|
+
"ClicksContext": "2",
|
9
|
+
"GoalCostContext": null,
|
10
|
+
"GoalCostSearch": null,
|
11
|
+
"GoalConversionSearch": null,
|
12
|
+
"SumContext": "0",
|
13
|
+
"GoalConversionContext": null,
|
14
|
+
"StatDate": "2008-11-13",
|
15
|
+
"ShowsSearch": "7",
|
16
|
+
"CampaignID": 123451,
|
17
|
+
"ShowsContext": "2"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"ClicksSearch": "5",
|
21
|
+
"SumSearch": "0",
|
22
|
+
"SessionDepthSearch": null,
|
23
|
+
"SessionDepthContext": null,
|
24
|
+
"ClicksContext": "0",
|
25
|
+
"GoalCostContext": null,
|
26
|
+
"GoalCostSearch": null,
|
27
|
+
"GoalConversionSearch": null,
|
28
|
+
"SumContext": "10",
|
29
|
+
"GoalConversionContext": null,
|
30
|
+
"StatDate": "2008-11-14",
|
31
|
+
"ShowsSearch": "13",
|
32
|
+
"CampaignID": 123451,
|
33
|
+
"ShowsContext": "49"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"ClicksSearch": "12",
|
37
|
+
"SumSearch": "0",
|
38
|
+
"SessionDepthSearch": null,
|
39
|
+
"SessionDepthContext": null,
|
40
|
+
"ClicksContext": "4",
|
41
|
+
"GoalCostContext": null,
|
42
|
+
"GoalCostSearch": null,
|
43
|
+
"GoalConversionSearch": null,
|
44
|
+
"SumContext": "34",
|
45
|
+
"GoalConversionContext": null,
|
46
|
+
"StatDate": "2008-11-15",
|
47
|
+
"ShowsSearch": "324",
|
48
|
+
"CampaignID": 123451,
|
49
|
+
"ShowsContext": "213"
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
{"data":
|
2
|
+
[
|
3
|
+
{
|
4
|
+
"Rest":183.44,
|
5
|
+
"Status":"This campaign has been stopped",
|
6
|
+
"IsActive":"No",
|
7
|
+
"StatusArchive":"No",
|
8
|
+
"Login":"yand-10",
|
9
|
+
"CampaignID":123451,
|
10
|
+
"StatusShow":"No",
|
11
|
+
"StartDate":"2008-11-10",
|
12
|
+
"Sum":184,
|
13
|
+
"StatusModerate":"Yes",
|
14
|
+
"Clicks":7,
|
15
|
+
"Shows":29759,
|
16
|
+
"ManagerName":"",
|
17
|
+
"StatusActivating":"Yes",
|
18
|
+
"SumAvailableForTransfer":183.44,
|
19
|
+
"AgencyName":"",
|
20
|
+
"Name":"Campaign #1"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"Rest":0,
|
24
|
+
"Status":"The campaign is moved to the archive",
|
25
|
+
"IsActive":"No",
|
26
|
+
"StatusArchive":"Yes",
|
27
|
+
"Login":"yand-10",
|
28
|
+
"CampaignID":123452,
|
29
|
+
"StatusShow":"No",
|
30
|
+
"StartDate":"2008-12-02",
|
31
|
+
"Sum":87.77,
|
32
|
+
"StatusModerate":"Yes",
|
33
|
+
"Clicks":863,
|
34
|
+
"Shows":340558,
|
35
|
+
"ManagerName":"",
|
36
|
+
"StatusActivating":"Yes",
|
37
|
+
"SumAvailableForTransfer":0,
|
38
|
+
"AgencyName":"",
|
39
|
+
"Name":"Campaign #2"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"Rest":36.71,
|
43
|
+
"Status":"This campaign is running",
|
44
|
+
"IsActive":"yes",
|
45
|
+
"StatusArchive":"No",
|
46
|
+
"Login":"yand-10",
|
47
|
+
"CampaignID":123453,
|
48
|
+
"StatusShow":"No",
|
49
|
+
"StartDate":"2008-12-16",
|
50
|
+
"Sum":40,
|
51
|
+
"StatusModerate":"Yes",
|
52
|
+
"Clicks":52,
|
53
|
+
"Shows":26806,
|
54
|
+
"ManagerName":"",
|
55
|
+
"StatusActivating":"Yes",
|
56
|
+
"SumAvailableForTransfer":36.71,
|
57
|
+
"AgencyName":"",
|
58
|
+
"Name":"Campaign #3"
|
59
|
+
}
|
60
|
+
]
|
61
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"data":
|
3
|
+
{
|
4
|
+
"Phone": "123456789",
|
5
|
+
"DateCreate": "2008-11-10",
|
6
|
+
"FIO": "Account name",
|
7
|
+
"Email": "test@email.com",
|
8
|
+
"Login": "test",
|
9
|
+
"StatusArch": "no",
|
10
|
+
"Discount": 1,
|
11
|
+
"SmsPhone": "",
|
12
|
+
"Role": "client",
|
13
|
+
"NonResident": "no",
|
14
|
+
"SendNews": "no",
|
15
|
+
"SendAccNews": "no",
|
16
|
+
"SendWarn": "no"
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"Phone": "123456789",
|
5
|
+
"DateCreate": "2008-11-10",
|
6
|
+
"FIO": "Account name",
|
7
|
+
"Email": "test@email.com",
|
8
|
+
"Login": "test",
|
9
|
+
"StatusArch": "no",
|
10
|
+
"Discount": 1,
|
11
|
+
"SmsPhone": "",
|
12
|
+
"Role": "client",
|
13
|
+
"NonResident": "no",
|
14
|
+
"SendNews": "no",
|
15
|
+
"SendAccNews": "no",
|
16
|
+
"SendWarn": "no"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"Phone": "123456789",
|
20
|
+
"DateCreate": "2008-11-10",
|
21
|
+
"FIO": "Account name",
|
22
|
+
"Email": "test@email.com",
|
23
|
+
"Login": "test",
|
24
|
+
"StatusArch": "no",
|
25
|
+
"Discount": 1,
|
26
|
+
"SmsPhone": "",
|
27
|
+
"Role": "client",
|
28
|
+
"NonResident": "no",
|
29
|
+
"SendNews": "no",
|
30
|
+
"SendAccNews": "no",
|
31
|
+
"SendWarn": "no"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{"data":
|
2
|
+
[{"SendAccNews":"Yes",
|
3
|
+
"CampaignEmails":["test@email.com"],
|
4
|
+
"Discount":0,
|
5
|
+
"Login":"login",
|
6
|
+
"SmsPhone":"",
|
7
|
+
"Email":"test@email.com",
|
8
|
+
"Role":"Client",
|
9
|
+
"FIO":"Nam of client",
|
10
|
+
"DateCreate":"2008-11-10",
|
11
|
+
"StatusArch":"No",
|
12
|
+
"SendNews":"Yes",
|
13
|
+
"Phone":"",
|
14
|
+
"NonResident":"No",
|
15
|
+
"SendWarn":"Yes"}]}
|