cb-api 7.7.0 → 7.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,33 +4,34 @@ module Cb
4
4
  class << self
5
5
 
6
6
  def get(criteria)
7
- response cb_call(:get, criteria)
7
+ response cb_call(:get, criteria, Cb.configuration.host_site)
8
8
  end
9
9
 
10
10
  def create(criteria)
11
- response cb_call(:post, criteria)
11
+ response cb_call(:post, criteria, (criteria.host_site || Cb.configuration.host_site))
12
12
  end
13
13
 
14
14
  def update(criteria)
15
- response cb_call(:put, criteria)
15
+ response cb_call(:put, criteria, Cb.configuration.host_site)
16
16
  end
17
17
 
18
18
  def form(job_id)
19
19
  url = Cb.configuration.uri_application_form.sub(':did', job_id)
20
- response_hash = api_client.cb_get(url, headers: headers)
21
- Responses::ApplicationForm.new(response_hash)
20
+ response_hash = api_client.cb_get(url, headers: headers(Cb.configuration.host_site))
21
+ Responses::ApplicationForm.new response_hash
22
22
  end
23
23
 
24
24
  private
25
25
 
26
- def cb_call(http_method, criteria)
27
- options = { headers: headers }
26
+ def cb_call(http_method, criteria, host_site)
27
+ options = { headers: headers(host_site) }
28
+
28
29
  if [:post, :put].include? http_method
29
30
  options[:body] = criteria.to_json
30
31
  end
31
32
 
32
33
  uri = uri(criteria)
33
- api_client.method(:"cb_#{http_method}").call uri, options
34
+ api_client.method(:"cb_#{http_method}").call(uri, options)
34
35
  end
35
36
 
36
37
  def response(response_hash)
@@ -39,13 +40,13 @@ module Cb
39
40
 
40
41
  def uri(criteria)
41
42
  did = criteria.respond_to?(:application_did) ? criteria.application_did : ''
42
- Cb.configuration.uri_application.sub ':did', did
43
+ Cb.configuration.uri_application.sub(':did', did)
43
44
  end
44
45
 
45
- def headers
46
+ def headers(host_site)
46
47
  {
47
48
  'DeveloperKey' => Cb.configuration.dev_key,
48
- 'HostSite' => Cb.configuration.host_site,
49
+ 'HostSite' => host_site,
49
50
  'Content-Type' => 'application/json'
50
51
  }
51
52
  end
@@ -53,6 +54,7 @@ module Cb
53
54
  def api_client
54
55
  Cb::Utils::Api.instance
55
56
  end
57
+
56
58
  end
57
59
  end
58
60
  end
@@ -3,8 +3,8 @@ module Cb
3
3
  module Application
4
4
  class Create
5
5
  extend Cb::Utils::FluidAttributes
6
- fluid_attr_accessor :job_did, :is_submitted, :external_user_id, :vid, :bid, :sid, :site_id, :ipath_id, :tn_did, :resume,
7
- :cover_letter, :responses
6
+ fluid_attr_accessor :job_did, :is_submitted, :external_user_id, :vid, :bid, :sid, :site_id, :ipath_id, :tn_did, :host_site,
7
+ :resume, :cover_letter, :responses
8
8
 
9
9
  def to_json
10
10
  crit = {
@@ -18,7 +18,7 @@ module Cb
18
18
  def headers
19
19
  {
20
20
  'DeveloperKey' => Cb.configuration.dev_key,
21
- 'HostSite' => Cb.configuration.host_site,
21
+ 'HostSite' => (args[:host_site] || Cb.configuration.host_site),
22
22
  'Content-Type' => 'application/json'
23
23
  }
24
24
  end
data/lib/cb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cb
2
- VERSION = '7.7.0'
2
+ VERSION = '7.8.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cb-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.7.0
4
+ version: 7.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-09 00:00:00.000000000 Z
12
+ date: 2014-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty