6
6
# Author:: jlopezn@neonline.cl
7
7
class BingAdsApiTest < ActiveSupport ::TestCase
8
8
9
+ def setup
10
+ @username = ""
11
+ @password = ""
12
+ @developer_token = ""
13
+ @customer_id = ""
14
+ @account_id = ""
15
+ @auth_token = ""
16
+ end
17
+
9
18
test "truth" do
10
19
assert_kind_of Module , BingAdsApi
11
20
end
@@ -53,11 +62,11 @@ class BingAdsApiTest < ActiveSupport::TestCase
53
62
54
63
test "create client proxy" do
55
64
options = {
56
- :username => "desarrollo_neonline" ,
57
- :password => "neonline2013" ,
58
- :developer_token => "BBD37VB98" ,
59
- :customer_id => "21021746" ,
60
- :account_id => "5978083" ,
65
+ :username => @username ,
66
+ :password => @password ,
67
+ :developer_token => @developer_token ,
68
+ :customer_id => @customer_id ,
69
+ :account_id => @account_id ,
61
70
:wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl"
62
71
}
63
72
client = BingAdsApi ::ClientProxy . new ( options )
@@ -71,11 +80,11 @@ class BingAdsApiTest < ActiveSupport::TestCase
71
80
72
81
test "create client proxy with additional settings" do
73
82
options = {
74
- :username => "desarrollo_neonline" ,
75
- :password => "neonline2013" ,
76
- :developer_token => "BBD37VB98" ,
77
- :customer_id => "21021746" ,
78
- :account_id => "5978083" ,
83
+ :username => @username ,
84
+ :password => @password ,
85
+ :developer_token => @developer_token ,
86
+ :customer_id => @customer_id ,
87
+ :account_id => @account_id ,
79
88
:wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl" ,
80
89
:proxy => {
81
90
:logger => Rails . logger ,
@@ -91,13 +100,42 @@ class BingAdsApiTest < ActiveSupport::TestCase
91
100
end
92
101
93
102
103
+ test "create oauth client proxy" do
104
+
105
+ options = {
106
+ :authentication_token => @auth_token ,
107
+ :developer_token => @developer_token ,
108
+ :customer_id => @customer_id ,
109
+ :account_id => @account_id ,
110
+ :wsdl_url => "https://api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl" ,
111
+ :proxy => {
112
+ :logger => Rails . logger ,
113
+ :encoding => "UTF-8"
114
+ }
115
+ }
116
+ client = BingAdsApi ::ClientProxy . new ( options )
117
+ #puts client.inspect
118
+ assert !client . nil? , "Client proxy not created"
119
+
120
+ #puts client.service
121
+ assert !client . service . nil? , "Service client not created"
122
+
123
+ #call service method
124
+ assert_nothing_raised ( Exception , "Service call raised exception" ) {
125
+ response = client . call ( :get_campaigns_by_account_id ,
126
+ message : { Account_id : "2642632" } )
127
+ puts response
128
+ }
129
+ end
130
+
131
+
94
132
test "call service" do
95
133
options = {
96
- :username => "desarrollo_neonline" ,
97
- :password => "neonline2013" ,
98
- :developer_token => "BBD37VB98" ,
99
- :customer_id => "21021746" ,
100
- :account_id => "5978083" ,
134
+ :username => @username ,
135
+ :password => @password ,
136
+ :developer_token => @developer_token ,
137
+ :customer_id => @customer_id ,
138
+ :account_id => @account_id ,
101
139
:wsdl_url => "https://api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl"
102
140
}
103
141
@@ -113,11 +151,11 @@ class BingAdsApiTest < ActiveSupport::TestCase
113
151
test "create and call from config" do
114
152
config = BingAdsApi ::Config . instance
115
153
options = {
116
- :username => "desarrollo_neonline" ,
117
- :password => "neonline2013" ,
118
- :developer_token => "BBD37VB98" ,
119
- :customer_id => "21021746" ,
120
- :account_id => "5978083" ,
154
+ :username => @username ,
155
+ :password => @password ,
156
+ :developer_token => @developer_token ,
157
+ :customer_id => @customer_id ,
158
+ :account_id => @account_id ,
121
159
:wsdl_url => config . service_wsdl ( :sandbox , :campaign_management )
122
160
}
123
161
0 commit comments