Skip to content

Commit

Permalink
Merge pull request #4 from vijithv/pagination
Browse files Browse the repository at this point in the history
PLATFORM-154 Pagination
  • Loading branch information
vijithv authored Jul 10, 2019
2 parents edba2b6 + 7f54c90 commit 649690e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 23 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ This is the **Ruby** library of [Instamojo REST API](https://www.instamojo.com/d
This will assist you to programmatically create, edit and delete links on Instamojo. Also supports [RAP](https://www.instamojo.com/developers/request-a-payment-api/) api for payments request, listing and status.

## Installation
`gem install Instamojo-rb`
`gem install instamojo-ruby`
For your Rails/bundler projects:
`gem 'Instamojo-rb'`
`gem 'instamojo-ruby'`

## Usage
### Set API keys
Expand Down Expand Up @@ -47,6 +47,11 @@ _Helper methods_ for `Link`:
client.links_list
#=> Array of Instamojo::Link objects
```
##### Supports optional pagination
```ruby
client.links_list(page:1, limit:10)
#=> Array of 10 Link objects (page 1)
```

#### Create a new product
##### Required:
Expand Down Expand Up @@ -142,6 +147,11 @@ Details are documented [here](https://www.instamojo.com/developers/rest/#toc-pay
client.payments_list
#=> Returns array of Payment objects
```
##### Supports optional pagination
```ruby
client.payments_list(page:1, limit:10)
#=> Array of 10 Payment objects (page 1)
```
#### Detail or status of a payment
```ruby
payment = client.payment_detail('MOJxxx06000F97367750')
Expand All @@ -161,6 +171,11 @@ payment_request = client.payment_request({amount:100, purpose: 'api', send_email
payment_requests = client.payment_requests_list
#=> Returns array of PaymentRequest objects
```
##### Supports optional pagination
```ruby
client.payment_requests_list(page:1, limit:10)
#=> Array of 10 PaymentRequest objects (page 1)
```
#### Status of payment request
You can get the status of a payment_request from the id you obtained after making payment request.
```ruby
Expand All @@ -178,7 +193,11 @@ payment_request = client.payment_request_status('8726f8c5001e426f8b24e908b276168
refunds = client.refunds_list
#=> Returns array of Refund objects
```

##### Supports optional pagination
```ruby
client.refunds_list(page:1, limit:10)
#=> Array of 10 Refund objects (page 1)
```
#### Create a new refund
##### Required:
* `payment_id` - Payment ID of the payment against which you're initiating the refund.
Expand Down
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "Instamojo-rb"
gem.homepage = "http://github.com/AnkurGel/Instamojo-rb"
gem.name = "instamojo-ruby"
gem.homepage = "http://github.com/Instamojo/Instamojo-rb"
gem.license = "MIT"
gem.summary = %Q{Instamojo Ruby library - Assists you to programmatically create, edit and delete offers on Instamojo}
gem.description = %Q{Instamojo Ruby library - Assists you to programmatically create, edit and delete offers on Instamojo. Also supports listing, updation and details of Payments, Payments Requests and Refunds.}
gem.email = "ankurgel@gmail.com"
gem.authors = ["Ankur Goel"]
gem.email = "dev-accounts@instamojo.com"
gem.authors = ["Instamojo Technologies"]
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new
Expand All @@ -38,7 +38,7 @@ Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "Instamojo-rb #{version}"
rdoc.title = "instamojo-ruby #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.2
12 changes: 6 additions & 6 deletions Instamojo-rb.gemspec → instamojo-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
# stub: Instamojo-rb 1.1.0 ruby lib

Gem::Specification.new do |s|
s.name = "Instamojo-rb"
s.version = "1.1.0"
s.name = "instamojo-ruby"
s.version = "1.1.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Ankur Goel"]
s.authors = ["Instamojo Technologies"]
s.date = "2015-12-18"
s.description = "Instamojo Ruby library - Assists you to programmatically create, edit and delete offers on Instamojo. Also supports listing, updation and details of Payments, Payments Requests and Refunds."
s.email = "ankurgel@gmail.com"
s.email = "dev-accounts@instamojo.com"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.md",
Expand All @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
".rspec",
"Gemfile",
"Gemfile.lock",
"Instamojo-rb.gemspec",
"instamojo-ruby.gemspec",
"LICENSE.txt",
"README.md",
"README.rdoc",
Expand All @@ -44,7 +44,7 @@ Gem::Specification.new do |s|
"spec/Instamojo-rb_spec.rb",
"spec/spec_helper.rb"
]
s.homepage = "http://github.com/AnkurGel/Instamojo-rb"
s.homepage = "http://github.com/Instamojo/Instamojo-rb"
s.licenses = ["MIT"]
s.rubygems_version = "2.2.2"
s.summary = "Instamojo Ruby library - Assists you to programmatically create, edit and delete offers on Instamojo"
Expand Down
17 changes: 9 additions & 8 deletions lib/client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ def authenticate(username = nil, password = nil, options = {}, &block)
end

# GET /links
def links_list
get('links')
def links_list(opts = {})
get('links', opts)
@response.success? ? @response.body[:links].map { |link| Instamojo::Link.new link, self } : @response
end


# GET /links/:slug
def link_detail(slug)
slug = slug.slug if slug.instance_of? Instamojo::Link
Expand Down Expand Up @@ -125,8 +126,8 @@ def upload_file(filepath)


# GET /payments
def payments_list
get('payments')
def payments_list(opts = {})
get('payments', opts)
@response.success? ? @response.body[:payments].map { |payment| Instamojo::Payment.new payment, self } : @response
end

Expand All @@ -145,8 +146,8 @@ def payment_request(options, &block)
end

# GET /payment-requests
def payment_requests_list
get('payment-requests')
def payment_requests_list(opts = {})
get('payment-requests', opts)
@response.success? ? @response.body[:payment_requests].map { |payment_request| Instamojo::PaymentRequest.new payment_request, self } : @response
end

Expand All @@ -157,8 +158,8 @@ def payment_request_status(payment_request_id)
end

# GET /refunds
def refunds_list
get('refunds')
def refunds_list(opts = {})
get('refunds', opts)
@response.success? ? @response.body[:refunds].map { |refund| Instamojo::Refund.new refund, self } : @response
end

Expand Down

0 comments on commit 649690e

Please sign in to comment.