seller_ledger-ruby 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 434363366daf337993198517b9e6d09863f0d9468eb5349afe01b33f36f0b88f
4
+ data.tar.gz: 27b1e0190cf222b859969332cb2df177271f1da740010ad5143cd8d601c8e8a2
5
+ SHA512:
6
+ metadata.gz: dded41a31c8235e4006e1ed7e4c2f808f4d63e374b09f637341b7faf507c2282d3ceb80d172ecaa03e72d5e873308905296c661fa1698f1eacb4e8e32e322611
7
+ data.tar.gz: d092730d6981b17c778dee32c0555438125ea5afa77b654f3f40157ea6a53ba6c3a13f2b23a184a42e366f7d78874c9c14a04f5fe0421202e037117b753f22d2
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2024-04-29
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at aleccarper@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in seller_ledger-ruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ seller_ledger-ruby (1.0.0)
5
+ faraday
6
+ json
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.1)
13
+ faraday (2.9.0)
14
+ faraday-net_http (>= 2.0, < 3.2)
15
+ faraday-net_http (3.1.0)
16
+ net-http
17
+ json (2.7.2)
18
+ language_server-protocol (3.17.0.3)
19
+ net-http (0.4.1)
20
+ uri
21
+ parallel (1.24.0)
22
+ parser (3.3.0.5)
23
+ ast (~> 2.4.1)
24
+ racc
25
+ racc (1.7.3)
26
+ rainbow (3.1.1)
27
+ rake (13.2.1)
28
+ regexp_parser (2.9.0)
29
+ rexml (3.2.6)
30
+ rspec (3.13.0)
31
+ rspec-core (~> 3.13.0)
32
+ rspec-expectations (~> 3.13.0)
33
+ rspec-mocks (~> 3.13.0)
34
+ rspec-core (3.13.0)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-expectations (3.13.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.13.0)
39
+ rspec-mocks (3.13.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.13.0)
42
+ rspec-support (3.13.1)
43
+ rubocop (1.63.2)
44
+ json (~> 2.3)
45
+ language_server-protocol (>= 3.17.0)
46
+ parallel (~> 1.10)
47
+ parser (>= 3.3.0.2)
48
+ rainbow (>= 2.2.2, < 4.0)
49
+ regexp_parser (>= 1.8, < 3.0)
50
+ rexml (>= 3.2.5, < 4.0)
51
+ rubocop-ast (>= 1.31.1, < 2.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 2.4.0, < 3.0)
54
+ rubocop-ast (1.31.2)
55
+ parser (>= 3.3.0.4)
56
+ ruby-progressbar (1.13.0)
57
+ unicode-display_width (2.5.0)
58
+ uri (0.13.0)
59
+
60
+ PLATFORMS
61
+ x86_64-linux
62
+
63
+ DEPENDENCIES
64
+ rake (~> 13.0)
65
+ rspec (~> 3.0)
66
+ rubocop (~> 1.21)
67
+ seller_ledger-ruby!
68
+
69
+ BUNDLED WITH
70
+ 2.4.3
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # SellerLedger API Gem
2
+
3
+ ## Installation
4
+
5
+ Install the gem and add to the application's Gemfile by executing:
6
+
7
+ $ bundle add seller_ledger
8
+
9
+ If bundler is not being used to manage dependencies, install the gem by executing:
10
+
11
+ $ gem install seller_ledger
12
+
13
+ ## Usage
14
+
15
+ This is a simple Ruby wrapper for the Seller Ledger API. Please refer to the [official documentation](https://developers.sellerledger.com/?ruby#seller-ledger-api) for usage examples.
16
+
17
+ ## Contributing
18
+
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sellerledger/seller_ledger-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sellerledger/seller_ledger-ruby/blob/master/CODE_OF_CONDUCT.md).
20
+
21
+ ## Code of Conduct
22
+
23
+ Everyone interacting in the Seller Ledger project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sellerledger/seller_ledger-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ class Client
5
+ module Categories
6
+ def list_categories(options = {})
7
+ paginated_request(
8
+ "/v1/categories",
9
+ options,
10
+ "categories"
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ class Client
5
+ module ExpenseTransactions
6
+ def list_expense_transactions(params = {})
7
+ paginated_request(
8
+ "/v1/transactions/expenses",
9
+ params,
10
+ "transactions"
11
+ )
12
+ end
13
+
14
+ def create_expense_transaction(params)
15
+ post("/v1/transactions/expenses", params)
16
+ end
17
+
18
+ def update_expense_transaction(id, params)
19
+ put("/v1/transactions/expenses/#{id}", params)
20
+ end
21
+
22
+ def get_expense_transaction(id)
23
+ get("/v1/transactions/expenses/#{id}")
24
+ end
25
+
26
+ def delete_expense_transaction(id)
27
+ delete("/v1/transactions/expenses/#{id}")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ class Client
5
+ module IncomeTransactions
6
+ def list_income_transactions(params = {})
7
+ paginated_request(
8
+ "/v1/transactions/income",
9
+ params,
10
+ "transactions"
11
+ )
12
+ end
13
+
14
+ def create_income_transaction(params)
15
+ post("/v1/transactions/income", params)
16
+ end
17
+
18
+ def update_income_transaction(id, params)
19
+ put("/v1/transactions/income/#{id}", params)
20
+ end
21
+
22
+ def get_income_transaction(id)
23
+ get("/v1/transactions/income/#{id}")
24
+ end
25
+
26
+ def delete_income_transaction(id)
27
+ delete("/v1/transactions/income/#{id}")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ class Client
5
+ module MileageTransactions
6
+ def list_mileage_transactions(params = {})
7
+ paginated_request(
8
+ "/v1/transactions/mileage",
9
+ params,
10
+ "transactions"
11
+ )
12
+ end
13
+
14
+ def create_mileage_transaction(params)
15
+ post("/v1/transactions/mileage", params)
16
+ end
17
+
18
+ def update_mileage_transaction(id, params)
19
+ put("/v1/transactions/mileage/#{id}", params)
20
+ end
21
+
22
+ def get_mileage_transaction(id)
23
+ get("/v1/transactions/mileage/#{id}")
24
+ end
25
+
26
+ def delete_mileage_transaction(id)
27
+ delete("/v1/transactions/mileage/#{id}")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ class Client
5
+ module Transactions
6
+ def list_transactions(params = {})
7
+ paginated_request(
8
+ "/v1/transactions",
9
+ params,
10
+ "transactions"
11
+ )
12
+ end
13
+
14
+ def get_transaction(id)
15
+ get("/v1/transactions/#{id}")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "json"
5
+ require "seller_ledger/client/categories"
6
+ require "seller_ledger/client/transactions"
7
+ require "seller_ledger/client/mileage_transactions"
8
+ require "seller_ledger/client/income_transactions"
9
+ require "seller_ledger/client/expense_transactions"
10
+
11
+ module SellerLedger
12
+ class Client
13
+ include SellerLedger::Client::Categories
14
+ include SellerLedger::Client::Transactions
15
+ include SellerLedger::Client::MileageTransactions
16
+ include SellerLedger::Client::IncomeTransactions
17
+ include SellerLedger::Client::ExpenseTransactions
18
+
19
+ def initialize(token:, url: "https://api.sellerledger.com")
20
+ @token = token
21
+ @url = url
22
+ end
23
+
24
+ def post(url, params = {})
25
+ request(:post, url, params).body
26
+ end
27
+
28
+ def get(url, params = {})
29
+ request(:get, url, params).body
30
+ end
31
+
32
+ def put(url, params = {})
33
+ request(:put, url, params).body
34
+ end
35
+
36
+ def delete(url)
37
+ request(:delete, url).body
38
+ end
39
+
40
+ def request(method, url, params)
41
+ response = agent.send(method, url, params)
42
+ raise SellerLedger::Errors::Unauthenticated.new if response.status == 401
43
+ raise SellerLedger::Errors::Generic.new(response.body["error"]) if response.body["error"].present?
44
+ response
45
+ end
46
+
47
+ def paginated_request(url, params, results_key)
48
+ response = request(:get, url, params)
49
+ {
50
+ "total" => response.headers["x-total"].to_i,
51
+ "total_pages" => response.headers["x-total-pages"].to_i,
52
+ "per_page" => response.headers["x-per-page"].to_i,
53
+ "page_number" => response.headers["x-page"].to_i,
54
+ "next_page_number" => response.headers["x-next-page"].to_i,
55
+ "prev_page_number" => response.headers["x-prev-page"].to_i,
56
+ results_key => response.body[results_key]
57
+ }
58
+ end
59
+
60
+ private
61
+
62
+ def agent
63
+ @agent ||= Faraday.new(@url) do |f|
64
+ f.request :authorization, "token", @token
65
+ f.request :json
66
+ f.response :json
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ class Errors
5
+
6
+ class Unauthenticated < StandardError
7
+ end
8
+
9
+ class Generic < StandardError
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SellerLedger
4
+ MAJOR = 1
5
+
6
+ MINOR = 0
7
+
8
+ PATCH = 0
9
+
10
+ VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
11
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "seller_ledger/client"
4
+ require "seller_ledger/errors"
5
+
6
+ module SellerLedger
7
+ class << self
8
+ def new(token, url: "https://api.sellerledger.com")
9
+ SellerLedger::Client.new(token: token, url: url)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module SellerLedger
2
+ module Ruby
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seller_ledger-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Reeth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Ruby wrapper for interacting with the Seller Ledger API
42
+ email:
43
+ - kevin@sellerledger.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rubocop.yml"
49
+ - CHANGELOG.md
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - README.md
54
+ - Rakefile
55
+ - lib/seller_ledger.rb
56
+ - lib/seller_ledger/client.rb
57
+ - lib/seller_ledger/client/categories.rb
58
+ - lib/seller_ledger/client/expense_transactions.rb
59
+ - lib/seller_ledger/client/income_transactions.rb
60
+ - lib/seller_ledger/client/mileage_transactions.rb
61
+ - lib/seller_ledger/client/transactions.rb
62
+ - lib/seller_ledger/errors.rb
63
+ - lib/seller_ledger/version.rb
64
+ - sig/seller_ledger/ruby.rbs
65
+ homepage: https://developers.sellerledger.com/?ruby#seller-ledger-api
66
+ licenses: []
67
+ metadata:
68
+ homepage_uri: https://developers.sellerledger.com/?ruby#seller-ledger-api
69
+ source_code_uri: https://github.com/sellerledger/seller_ledger-ruby
70
+ changelog_uri: https://github.com/sellerledger/seller_ledger-ruby/blob/main/CHANGELOG.md
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.6.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.3.7
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Seller Ledger API Client
90
+ test_files: []