alegra 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: fe72ddb175b67a063af16e4edbf8667eeb5f3f0b
4
- data.tar.gz: 153028fb170b9b94b4f24de326e4b047936c178d
3
+ metadata.gz: 8449e5cbf7915fbc40fd7774552e0fae7a87ef6c
4
+ data.tar.gz: 3310cdab9187dbee1cd746c5cfced9bb18a13d2d
5
5
  SHA512:
6
- metadata.gz: 677d0d327b02314520490ff13524c27fa032bf8fd6f08045a551a530f15ad99cfb4b26accf9a13ad49b3d6b2debda86f14359f237b3fa977813b334a9c8f6ae3
7
- data.tar.gz: bbeab0df754e76f143bc738ec7973eb99181eabf2a3baf803af861a217bca6dcab7fa2204a26725b08372ecf95df4692926ff66d01528b4a71cf6e5da97ebd3a
6
+ metadata.gz: 23c701feb6d7ce8938cab5102505033a169d4fca79c6e765b0d123aabef0aeb2c7f67e21f4ce1a26518a13bab9006ab6e6c6d8c7e8f808172e419105a09217e9
7
+ data.tar.gz: e5a41d8a8f9f0500c75677288daae2047dcdcb779f17d24767f02fad102d7b4454f4d8bc0ced8e049ecf441023193845fea52642758dfad03a06b765eb448aa1
@@ -19,6 +19,16 @@ module Alegra
19
19
  request.post(url, params)
20
20
  end
21
21
 
22
+ def put(url, params={})
23
+ request = Alegra::Request.new(@setup.host, @setup.path, @setup.token)
24
+ request.put(url, params)
25
+ end
26
+
27
+ def delete(url, params={})
28
+ request = Alegra::Request.new(@setup.host, @setup.path, @setup.token)
29
+ request.delete(url, params)
30
+ end
31
+
22
32
  def invoices
23
33
  Alegra::Invoices.new(self)
24
34
  end
@@ -27,4 +37,4 @@ module Alegra
27
37
  Alegra::Contacts.new(self)
28
38
  end
29
39
  end
30
- end
40
+ end
@@ -20,10 +20,53 @@ module Alegra
20
20
 
21
21
  # @param params [ Hash ]
22
22
  # - name [ String ]
23
+ # - identification [ String ]
24
+ # - email [ String ]
25
+ # - phone_primary [ String ]
26
+ # - phone_secondary [ String ]
27
+ # - fax [ String ]
28
+ # - mobile [ String ]
29
+ # - observations [ String ]
30
+ # - ignore_repeated [ Boolean ]
31
+ # - price_list [ Hash ]
32
+ # - seller [ Hash ]
33
+ # - term [ Hash ]
34
+ # - type [ Array ]
35
+ # - address [ Hash ]
36
+ # - internal_contacts [ Array ]
23
37
  # @return [ Hash ]
24
38
  def create(params)
25
39
  _params = params.deep_camel_case_lower_keys
26
40
  client.post('contacts', _params)
27
41
  end
42
+
43
+ # @param id [ Integer ]
44
+ # @param params [ Hash ]
45
+ # - name [ String ]
46
+ # - identification [ String ]
47
+ # - email [ String ]
48
+ # - phone_primary [ String ]
49
+ # - phone_secondary [ String ]
50
+ # - fax [ String ]
51
+ # - mobile [ String ]
52
+ # - observations [ String ]
53
+ # - ignore_repeated [ Boolean ]
54
+ # - price_list [ Hash ]
55
+ # - seller [ Hash ]
56
+ # - term [ Hash ]
57
+ # - type [ Array ]
58
+ # - address [ Hash ]
59
+ # - internal_contacts [ Array ]
60
+ # @return [ Hash ]
61
+ def update(id, params)
62
+ _params = params.deep_camel_case_lower_keys
63
+ client.put("contacts/#{ id }", _params)
64
+ end
65
+
66
+ # @param id [ Integer ]
67
+ # @return [ Hash ]
68
+ def delete(id)
69
+ client.delete("contacts/#{ id }")
70
+ end
28
71
  end
29
72
  end
@@ -39,6 +39,39 @@ module Alegra
39
39
  _params = params.deep_camel_case_lower_keys
40
40
  client.post('invoices', _params)
41
41
  end
42
+
43
+ # Creates a invoice
44
+ # @param params [ Hash ]
45
+ # - date [ String ]
46
+ # - due_date [ String ]
47
+ # - price_list [ Array ]
48
+ # - currency [ Array ]
49
+ # - payments [ Array ]
50
+ # - client [ Integer ] or [ Hash ]
51
+ # - items [ Array ]
52
+ # - observations [ Array ]
53
+ # - anotations [ Array ]
54
+ # - terms_conditions [ Array ]
55
+ # - status [ String ]
56
+ # - number_template [ String ]
57
+ # - retenctions [ Array ]
58
+ # - seller [ String ]
59
+ # @return [ Hash ]
60
+ def update(id, params)
61
+ _params = params.deep_camel_case_lower_keys
62
+ client.put("invoices/#{ id }", _params)
63
+ end
64
+
65
+ # @param id [ Integer ]
66
+ # @param params [ Hash ]
67
+ # - emails [ Array ]
68
+ # - send_copy_to_user [ Boolean ]
69
+ # - invoiceType [ String ]
70
+ # @return [ Hash ]
71
+ def send_by_email(id, params)
72
+ _params = params.deep_camel_case_lower_keys
73
+ client.post("invoices/#{ id }/email", _params)
74
+ end
42
75
  end
43
76
  end
44
77
 
@@ -33,6 +33,33 @@ module Alegra
33
33
  return JSON.parse(response.body)
34
34
  end
35
35
 
36
+ def put(url, params={})
37
+ params = JSON.generate(params)
38
+ response = @session.put do |req|
39
+ req.url "#{ @path }#{ url }"
40
+ req.headers['Content-Type'] = 'application/json'
41
+ req.headers['Accept'] = 'application/json'
42
+ req.headers['Authorization'] = "Basic #{ @token }"
43
+ req.body = params
44
+ end
45
+ cast_error(response) unless (response.status == 200 || response.status == 201)
46
+ return JSON.parse(response.body)
47
+ end
48
+
49
+
50
+ def delete(url, params={})
51
+ params = JSON.generate(params)
52
+ response = @session.delete do |req|
53
+ req.url "#{ @path }#{ url }"
54
+ req.headers['Content-Type'] = 'application/json'
55
+ req.headers['Accept'] = 'application/json'
56
+ req.headers['Authorization'] = "Basic #{ @token }"
57
+ req.body = params
58
+ end
59
+ cast_error(response) unless (response.status == 200 || response.status == 201)
60
+ return JSON.parse(response.body)
61
+ end
62
+
36
63
  def cast_error(response)
37
64
  message = response.body.empty? ? response.body : JSON.parse(response.body)['message']
38
65
  error_map = {
@@ -1,3 +1,3 @@
1
1
  module Alegra
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alegra
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
  - Diego Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-14 00:00:00.000000000 Z
11
+ date: 2016-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler