bumeran 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7653fd856f6e286e08d343200b9a70e996f6b16
4
- data.tar.gz: 2312b5ec3b15bb67a866127f6608b71ee14edc9c
3
+ metadata.gz: dbb361b946aec3f04acda6cbc430e529d3c8bf44
4
+ data.tar.gz: 1bb3aea660def813b261a9bc3a94f13b31b4a0f6
5
5
  SHA512:
6
- metadata.gz: 293417c1103e148b6363cd5e46e82fcba205b5881716f4ea727a4831257dfff3a6a1765e7845fbb98c1aa7f07d52f10e7199010dbbf022275245c3a967311e1f
7
- data.tar.gz: 513cc54d365a38e9af7abcab47cc55dfd2ce0f1afd9572ec8531c548f51e77feec340bbb0e3280b31761d6bf34e5486e33d43466241ea3d9820db3d7dc60de5d
6
+ metadata.gz: 02c562e4347a193477187af29183b465094e97c490fb4bc5058ad3ac4bf4c5207173eca2ecf7da8d8486dea1988299801b000927643f8c529c2ad339c4c04084
7
+ data.tar.gz: 6b44bfb51ee2e3f9671d5c7e4112c37ea8a0479a98fee973750041405c0a48a95a878da6b9392b9a19440f7c91af0e125c63c5a1f841bf6d8a54743b5512a0be
data/README.md CHANGED
@@ -10,7 +10,7 @@ Bumeran works with Rails 3.2 onwards. You can add it to your Gemfile with:
10
10
  gem 'bumeran'
11
11
  ```
12
12
 
13
- ...or can fetch the lastest developer version with:
13
+ ...or can fetch the latest developer version with:
14
14
 
15
15
  ```ruby
16
16
  gem 'bumeran', :git => 'git@github.com:rfernand/bumeran.git', :branch => 'develop'
@@ -32,18 +32,31 @@ end
32
32
 
33
33
 
34
34
  And more that don't need an ID. All return a json object, and raise an error (401, 404, 500) if there was one:
35
- ### Create a new publication
35
+ ### Create and publish a new publication
36
36
  ```ruby
37
37
  publication = Bumeran::Publication.new
38
- Bumeran.publish(publication.body.to_json)
38
+ pais_id = 1 # 1 = Argentina
39
+ plan_publication_id = 30 # 30 = simple
40
+ Bumeran.publish(publication.body.to_json, pais_id, plan_publication_id)
39
41
  ```
40
- ### Get a publication
42
+ ### Get a publication data
41
43
  ```ruby
42
44
  Bumeran.get_publication(publication_id)
45
+ Bumeran.get_postulations_in_publication(publication_id)
43
46
  ```
44
- ### And a lot of more getters
45
47
 
46
- They recieve a corresponding object id and return a json object.
48
+ ### Destroy a publication
49
+ ```ruby
50
+ Bumeran.destroy_publication(publication_id)
51
+ ```
52
+ ### Discard a postulation
53
+ ```ruby
54
+ Bumeran.discard_postulation(publication_id)
55
+ ```
56
+
57
+ ### More getters
58
+
59
+ They receive a corresponding object id and return a json object.
47
60
 
48
61
  ```ruby
49
62
  Bumeran.get_estudio(estudio_id)
@@ -76,5 +89,7 @@ Bumeran.tipos_trabajo
76
89
  Bumeran.areas_estudio
77
90
  Bumeran.estados_estudio
78
91
  Bumeran.tipos_estudio
79
- Bumeran.tipos_estudio
80
92
  ```
93
+
94
+ ## TODO
95
+ - Add the missing methods of the postulaciones service
@@ -77,11 +77,63 @@ module Bumeran
77
77
  end
78
78
  end
79
79
 
80
- # Publicaciones
81
- def self.publish(json)
80
+ # Publicaciones / Avisos
81
+
82
+ # alias
83
+ def self.publicar_aviso(aviso_id, plan_publicacion_id, pais_id)
84
+ Bumeran.publish_publication(aviso_id, plan_publicacion_id, pais_id)
85
+ end
86
+
87
+ # alias
88
+ def self.create_aviso(json)
89
+ Bumeran.create_publication(json)
90
+ end
91
+
92
+ # alias
93
+ def self.get_aviso(aviso_id)
94
+ Bumeran.get_publication(aviso_id)
95
+ end
96
+
97
+ # alias
98
+ def self.get_postulaciones_en_aviso(aviso_id)
99
+ Bumeran.get_postulations_in_publication(aviso_id)
100
+ end
101
+
102
+ # alias
103
+ def self.destroy_aviso(aviso_id)
104
+ Bumeran.destroy_publication(aviso_id)
105
+ end
106
+
107
+ # creates and publish a publication
108
+ def self.publish(json, pais_id, plan_publication_id)
109
+ publication_id = Bumeran.create_publication(json)
110
+ Bumeran.publish_publication(publication_id, pais_id, plan_publication_id)
111
+ return publication_id
112
+ end
113
+
114
+ #
115
+
116
+ def self.create_publication(json)
117
+ Bumeran.initialize
118
+ create_publication_path = "/v0/empresas/avisos"
119
+ response = self.put(create_publication_path, @@options.merge(body: json, headers: { "Accept" => "application/json", "Content-Type" => "application/json"}))
120
+
121
+ if Parser.parse_response(response)
122
+ case response.code
123
+ when 201
124
+ # "Publication created, All good!"
125
+ return response # body contains id del proceso publicado
126
+ when 200
127
+ # "TODO: Uhm.. no idea, is this good?"
128
+ return response # body contains id del proceso publicado?
129
+ end
130
+ end
131
+ end
132
+
133
+ def self.publish_publication(publication_id, pais_id, plan_publication_id)
82
134
  Bumeran.initialize
83
- new_publish_path = "/v0/empresas/avisos"
84
- response = self.put(new_publish_path, @@options.merge(body: json, headers: { "Accept" => "application/json", "Content-Type" => "application/json"}))
135
+ publish_publication_path = "/v0/empresas/avisos/#{publication_id}/publicacion/#{plan_publication_id}"
136
+ response = self.put(publish_publication_path, @@options.merge(query: @@options[:query].merge({paisId: pais_id})))
85
137
 
86
138
  if Parser.parse_response(response)
87
139
  case response.code
@@ -96,12 +148,29 @@ module Bumeran
96
148
  end
97
149
 
98
150
  def self.get_publication(publication_id)
99
- get_publish_path = "/v0/empresas/avisos/#{publication_id}"
100
- response = self.get(get_publish_path, @@options)
151
+ Bumeran.initialize
152
+ get_publication_path = "/v0/empresas/avisos/#{publication_id}"
153
+ response = self.get(get_publication_path, @@options)
154
+
155
+ return Parser.parse_response_to_json(response)
156
+ end
157
+
158
+ def self.get_postulations_in_publication(publication_id)
159
+ Bumeran.initialize
160
+ get_postulations_in_publication_path = "/v0/empresas/avisos/#{publication_id}/postulaciones"
161
+ response = self.get(get_postulations_in_publication_path, @@options)
101
162
 
102
163
  return Parser.parse_response_to_json(response)
103
164
  end
104
165
 
166
+ def self.destroy_publication(publication_id)
167
+ Bumeran.initialize
168
+ destroy_publication_path = "/v0/empresas/avisos/#{publication_id}"
169
+ response = self.delete(destroy_publication_path, @@options)
170
+
171
+ return Parser.parse_response(response)
172
+ end
173
+
105
174
  def self.areas
106
175
  @@areas.empty? ? get_areas : @@areas
107
176
  end
@@ -378,7 +447,12 @@ module Bumeran
378
447
  return Parser.parse_response_to_json(response)
379
448
  end
380
449
 
450
+ # alias
381
451
  def self.discard_postulacion(postulacion_id)
452
+ Bumeran.discard_postulation(postulacion_id)
453
+ end
454
+
455
+ def self.discard_postulation(postulacion_id)
382
456
  Bumeran.initialize
383
457
  discard_postulaciones_path = "/v0/empresas/postulaciones/#{postulacion_id}/descartar"
384
458
  response = self.put(discard_postulaciones_path, @@options)
@@ -1,3 +1,3 @@
1
1
  module Bumeran
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -8,23 +8,35 @@ describe Bumeran do
8
8
  Bumeran.has_valid_access_token?.should be_true
9
9
  end
10
10
 
11
- it 'can publish', publish: true do
11
+ it 'can create publication', create: true do
12
12
  publication = BumeranFixture.publication
13
- result = Bumeran.publish(publication.body.to_json)
13
+ result = Bumeran.create_aviso(publication.body.to_json)
14
14
  pp result
15
15
  result.to_i.should > 0
16
16
  end
17
17
 
18
- it 'can get publication', publish: true do
18
+ it 'can publish publication', create: true do
19
19
  publication = BumeranFixture.publication
20
- publication_id = Bumeran.publish(publication.body.to_json)
20
+ published_publication_id = Bumeran.publish(publication.body.to_json, 1, 30) # pais Argentina = 1, plan publicacion "simple" = 30
21
+ pp published_publication_id
22
+ published_publication_id.to_i.should > 0
23
+ end
24
+
25
+ it 'can create, get, publish and destroy publication', publish: true do
26
+ publication = BumeranFixture.publication
27
+ publication_id = Bumeran.create_aviso(publication.body.to_json)
21
28
  pp publication_id
22
- #binding.pry
23
-
24
29
  publication_id.should > 0
30
+
25
31
  publication = Bumeran.get_publication(publication_id)
26
- #binding.pry
27
32
  pp publication
33
+ publication["id"].should > 0
34
+
35
+ published_publication = Bumeran.publicar_aviso(publication_id, 1, 30) # pais Argentina = 1, plan publicacion "simple" = 30
36
+ pp published_publication
37
+
38
+ deleted_publication = Bumeran.destroy_aviso(publication_id)
39
+ pp deleted_publication
28
40
  end
29
41
 
30
42
  it 'can get areas', getters: true do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumeran
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Fernandez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -92,7 +92,6 @@ files:
92
92
  - Gemfile
93
93
  - Gemfile.lock
94
94
  - LICENSE
95
- - MIT-LICENSE
96
95
  - README.md
97
96
  - Rakefile
98
97
  - bumeran.gemspec
@@ -1,20 +0,0 @@
1
- Copyright 2015 Rodrigo Fernandez
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.