ey_services_fake 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,7 @@ module EyServicesFake
17
17
  end
18
18
 
19
19
  delete '/api/1/some_provisioned_service' do
20
+ content_type :json
20
21
  if parent.service_deprovisioning_handler
21
22
  instance_eval(&parent.service_deprovisioning_handler)
22
23
  else
@@ -25,6 +26,7 @@ module EyServicesFake
25
26
  end
26
27
 
27
28
  delete '/api/1/some_service_account' do
29
+ content_type :json
28
30
  if parent.service_account_cancel_handler
29
31
  instance_eval(&parent.service_account_cancel_handler)
30
32
  else
@@ -33,34 +35,24 @@ module EyServicesFake
33
35
  end
34
36
 
35
37
  post '/api/1/service_accounts_callback' do
38
+ content_type :json
36
39
  if parent.service_account_creation_handler
37
40
  instance_eval(&parent.service_account_creation_handler)
38
41
  else
39
42
  service_account = EY::ServicesAPI::ServiceAccountCreation.from_request(request.body.read)
40
43
  standard_response_params = parent.service_account_creation_params
41
- EY::ServicesAPI::ServiceAccountResponse.new(
42
- :provisioned_services_url => standard_response_params[:provisioned_services_url],
43
- :url => standard_response_params[:url],
44
- :configuration_url => standard_response_params[:configuration_url],
45
- :configuration_required => standard_response_params[:configuration_required],
46
- :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
47
- ).to_hash.to_json
44
+ EY::ServicesAPI::ServiceAccountResponse.new(parent.service_account_creation_params).to_hash.to_json
48
45
  end
49
46
  end
50
47
 
51
48
  post '/api/1/provisioned_services_callback' do
49
+ content_type :json
52
50
  if parent.service_provisioning_handler
53
51
  instance_eval(&parent.service_provisioning_handler)
54
52
  else
55
53
  provisioned_service = EY::ServicesAPI::ProvisionedServiceCreation.from_request(request.body.read)
56
54
  standard_response_params = parent.service_provisioned_params
57
- EY::ServicesAPI::ProvisionedServiceResponse.new(
58
- :url => standard_response_params[:url],
59
- :vars => standard_response_params[:vars],
60
- :configuration_required => standard_response_params[:configuration_required],
61
- :configuration_url => standard_response_params[:configuration_url],
62
- :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some provisioned service messages")
63
- ).to_hash.to_json
55
+ EY::ServicesAPI::ProvisionedServiceResponse.new(parent.service_provisioned_params).to_hash.to_json
64
56
  end
65
57
  end
66
58
 
@@ -136,7 +128,8 @@ module EyServicesFake
136
128
  :provisioned_services_url => "#{base_url}api/1/provisioned_services_callback",
137
129
  :url => "#{base_url}api/1/some_service_account",
138
130
  :configuration_url => "#{base_url}sso/some_service_account",
139
- :configuration_required => false
131
+ :configuration_required => false,
132
+ :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
140
133
  }
141
134
  end
142
135
 
@@ -149,6 +142,7 @@ module EyServicesFake
149
142
  :configuration_url => "#{base_url}sso/some_provisioned_service",
150
143
  :configuration_required => false,
151
144
  :url => "#{base_url}api/1/some_provisioned_service",
145
+ :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some provisioned service messages")
152
146
  }
153
147
  end
154
148
 
@@ -21,6 +21,7 @@ module EyServicesFake
21
21
  partner.services.each do |service|
22
22
  to_return << {"service" => service.attributes.merge('url' => URL_GEN.service(service)) }
23
23
  end
24
+ content_type :json
24
25
  to_return.to_json
25
26
  end
26
27
 
@@ -28,6 +29,7 @@ module EyServicesFake
28
29
  post '/api/1/partners/:partner_id/services' do |partner_id|
29
30
  partner = Partner.get!(partner_id)
30
31
  service_json = JSON.parse(request.body.read)["service"]
32
+ content_type :json
31
33
  if service_json["name"].to_s.empty?
32
34
  status 400
33
35
  {:error_messages => ["Name can't be blank"]}.to_json
@@ -41,6 +43,7 @@ module EyServicesFake
41
43
 
42
44
  get '/api/1/partners/:partner_id/services/:service_id' do |partner_id, service_id|
43
45
  partner = Partner.get!(partner_id)
46
+ content_type :json
44
47
  if service = partner.services.detect{ |s| s.id.to_s == service_id.to_s }
45
48
  {"service" => service.attributes}.to_json
46
49
  else
@@ -53,6 +56,7 @@ module EyServicesFake
53
56
  partner = Partner.get!(partner_id)
54
57
  service = partner.services.detect{ |s| s.id.to_s == service_id.to_s }
55
58
  update_params = JSON.parse(request.body.read)["service"]
59
+ content_type :json
56
60
  if update_params.key?("name") && update_params["name"].to_s.empty?
57
61
  status 400
58
62
  {:error_messages => ["Name can't be blank"]}.to_json
@@ -66,6 +70,7 @@ module EyServicesFake
66
70
  partner = Partner.get!(partner_id)
67
71
  service = partner.services.detect{ |s| s.id.to_s == service_id.to_s }
68
72
  service.destroy
73
+ content_type :json
69
74
  {}.to_json
70
75
  end
71
76
 
@@ -75,6 +80,7 @@ module EyServicesFake
75
80
  service_account = service.service_accounts.detect{ |sa| sa.id.to_s == service_account_id.to_s }
76
81
  service_account_atts = JSON.parse(request.body.read)["service_account"]
77
82
  service_account.update_attributes(service_account_atts)
83
+ content_type :json
78
84
  {}.to_json
79
85
  end
80
86
 
@@ -83,11 +89,13 @@ module EyServicesFake
83
89
  provisioned_service = service_account.provisioned_services.detect{ |ps| ps.id.to_s == provisioned_service_id.to_s}
84
90
  atts = JSON.parse(request.body.read)["provisioned_service"]
85
91
  provisioned_service.update_attributes(atts)
92
+ content_type :json
86
93
  {}.to_json
87
94
  end
88
95
 
89
96
  post '/api/1/partners/:partner_id/services/:service_id/service_accounts/:service_account_id/invoices' do |partner_id, service_id, service_account_id|
90
97
  invoice_params = JSON.parse(request.body.read)["invoice"]
98
+ content_type :json
91
99
  unless invoice_params['total_amount_cents'].is_a?(Fixnum)
92
100
  status 400
93
101
  return {:error_messages => ["Total Amount Cents must be an integer"]}.to_json
@@ -108,6 +116,7 @@ module EyServicesFake
108
116
  message_params = JSON.parse(request.body.read)["message"]
109
117
  message_type = message_params['message_type']
110
118
  subject = message_params['subject']
119
+ content_type :json
111
120
 
112
121
  if subject.to_s.empty?
113
122
  status 400
@@ -133,6 +142,7 @@ module EyServicesFake
133
142
  message_params = JSON.parse(request.body.read)["message"]
134
143
  subject = message_params['subject']
135
144
  message_type = message_params['message_type']
145
+ content_type :json
136
146
 
137
147
  if subject.to_s.empty?
138
148
  status 400
@@ -1,3 +1,3 @@
1
1
  module EyServicesFake
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_services_fake
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 8
10
- version: 0.3.8
9
+ - 9
10
+ version: 0.3.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacob Burkhart & Josh Lane
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-04 00:00:00 Z
18
+ date: 2012-04-05 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: sinatra