faxplus_api 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 798fb5fe6c1a20d813f70a36f5536faf816681dddd42ad51483b1dab2fa10b84
4
- data.tar.gz: 11a8889f8315641cc7beb609b4b71386703dcc7b391e45508c1699bccba0defd
3
+ metadata.gz: 4d7d5d99a832e5707096a02ae5209ea2984306a74d964345143acf573616fd9a
4
+ data.tar.gz: a049ba2bd56c73f3bdb6753a75cf73642128a916c750cc5519631e58bc5ee834
5
5
  SHA512:
6
- metadata.gz: 77d1fb41d4ca7cf0e7b86fe04b5c1d7c5b2ec4dd08efd519fd4e557e955217a8385a3e901f2cc87da797ab54a2b4b686ba39b262a243aa367963cf3b9064d57e
7
- data.tar.gz: a72a743da2f10cc80191f751869e534c025600e8aa897706ba04d2164d9ba5e7b1dda3659bff1d2fa031e61483a24763153b47a11af5c9a5b5cfd2ee7b3f2737
6
+ metadata.gz: 4a4c22a9b6bfd8a1f0d1afa06202c65ebf04739ca43fe860047a29278641ad17c42579c6a850a151e1fcefcea045926586852199e815d432355e9f388d1e7b0f
7
+ data.tar.gz: 9f7e41ed1231cd4bd97d8a465fe670dd8062c6659695b5842c01fe251f96e2248ec2ed8df581b47f76b730101b47154bb264e533c7a465d7d7126c51a7399d7f
data/README.md CHANGED
@@ -6,7 +6,7 @@ Faxplus is a Ruby library for interacting with faxplus APIs.
6
6
  To start using faxplus, you first need to add it to your Gemfile, with an entry such as this:
7
7
 
8
8
  ```ruby
9
- gem 'faxplus_ruby'
9
+ gem 'faxplus_api'
10
10
  ```
11
11
 
12
12
  Afterwards, run `bundle install`
@@ -43,7 +43,8 @@ client.fax.revoke(user_id: 'userid', fax_id: 'fax_id') # Delete a fax
43
43
  ## Files.
44
44
 
45
45
  ```ruby
46
- client.file.upload(user_id: 'userid') # Upload a file TODO: Need proper params how to send file
46
+ # Upload a file
47
+ client.file.upload(user_id: 'userid', data: {fax_file: File.open('pdf_file_path.pdf'), multipart: true}) => {:path => "/storage/transient-hsfhadhaskha.pdf"}
47
48
  client.file.get(user_id: 'userid', fax_id: 'fax_id') # Download fax file
48
49
  client.file.fax_report(user_id: 'userid', fax_id: 'fax_id') # Get fax confirmation report
49
50
  ```
@@ -51,8 +52,8 @@ client.file.fax_report(user_id: 'userid', fax_id: 'fax_id') # Get fax confirmati
51
52
 
52
53
  ```ruby
53
54
  client.outbox.list(user_id: 'userid') # List faxes in the outbox
54
- # TODO: require proper params here
55
- client.outbox.send(user_id: 'userid') # Send a fax
55
+ # file_path from the client.file.upload output path
56
+ client.outbox.send(user_id: 'userid', data: {from: "+12345667", to: ["+12345688"], files: [file_path]}) # Send a fax
56
57
  client.outbox.get(user_id: 'userid', outbox_fax_id: 'outbox_fax_id') # List outgoing faxes
57
58
  client.outbox.update(user_id: 'userid', outbox_fax_id: 'outbox_fax_id') # Delete an outgoing fax
58
59
  client.outbox.delete(user_id: 'userid', outbox_fax_id: 'outbox_fax_id') # Modify an outgoing fax
@@ -9,16 +9,16 @@ module FaxplusApi
9
9
  @base_url = client.base_url
10
10
  end
11
11
 
12
- def make_request(url: , data: , method: 'get')
12
+ def make_request(url:, data:, method: 'get', content_type: 'application/json')
13
13
  begin
14
14
  response = if method == 'post'
15
- RestClient.post(url, data.to_json, headers)
15
+ RestClient.post(url, data, headers(content_type))
16
16
  elsif method == 'put'
17
- RestClient.put(url, data.to_json, headers)
17
+ RestClient.put(url, data, headers(content_type))
18
18
  elsif method == 'get'
19
- RestClient.get(url, headers)
19
+ RestClient.get(url, headers(content_type))
20
20
  elsif method == 'delete'
21
- RestClient.delete(url, headers)
21
+ RestClient.delete(url, headers(content_type))
22
22
  end
23
23
  rescue RestClient::ExceptionWithResponse => e
24
24
  return { error: e.response.body }
@@ -31,9 +31,9 @@ module FaxplusApi
31
31
 
32
32
  private
33
33
 
34
- def headers
34
+ def headers(content_type)
35
35
  {
36
- 'Content-Type' => 'application/json',
36
+ 'Content-Type' => content_type,
37
37
  'Accept' => 'application/json',
38
38
  'Authorization' => "Bearer #{@access_token}"
39
39
  }
@@ -4,7 +4,7 @@ module FaxplusApi
4
4
  class File < Base
5
5
  def upload(url: "#{@base_url}/accounts/%{user_id}/files", user_id:, data: {})
6
6
  url = url % {user_id: user_id}
7
- make_request(url: url, data: data, method: 'post')
7
+ make_request(url: url, data: data, method: 'post', content_type: 'multipart/form-data')
8
8
  end
9
9
 
10
10
  def get(url: "#{@base_url}/accounts/%{user_id}/files/%{fax_id}", user_id:, fax_id:, data: {})
@@ -8,7 +8,7 @@ module FaxplusApi
8
8
  end
9
9
 
10
10
  def send(url: "#{@base_url}/accounts/%{user_id}/outbox", user_id:, data: {})
11
- url = url % {user_id: user_id, fax_id: fax_id}
11
+ url = url % {user_id: user_id}
12
12
  make_request(url: url, data: data, method: 'post')
13
13
  end
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faxplus_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dilkhush Soni
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-20 00:00:00.000000000 Z
11
+ date: 2024-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,15 +44,17 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: 1.8.6
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
55
- description:
54
+ version: 1.8.6
55
+ description: |2
56
+ A simple wrapper around faxplus's API.
57
+ For detailed documentation, please visit: https://github.com/dilkhush/faxplus-ruby/blob/main/README.md
56
58
  email:
57
59
  - dilkhushsoni2010@gmail.com
58
60
  executables: []
@@ -89,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
91
  - !ruby/object:Gem::Version
90
92
  version: '0'
91
93
  requirements: []
92
- rubygems_version: 3.1.2
94
+ rubygems_version: 3.1.6
93
95
  signing_key:
94
96
  specification_version: 4
95
97
  summary: A simple wrapper around faxplus's API