core_merchant 0.1.0 → 0.2.0

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: 6d92b65405d20766e71e2510e5bc3c79dcbd1a0821721f83262c28c4ecb3e5f6
4
- data.tar.gz: 1da82246e7b5145805e4c31d24b42fd7acf77d7ab541166ae5cc450a008c2b45
3
+ metadata.gz: e3770d6e4ff989b5f5e8ec48d7fb909b472b7c43b0f19fe7de933903a7d6c2ec
4
+ data.tar.gz: 7f4ab1681347258d44ca2bcc072ffc1f95f609153153d976406a0120ff1c4f11
5
5
  SHA512:
6
- metadata.gz: ec3490ecc9fd035a910657eea62a2326cf87bccd8dc4b578c44850b3eba8e0478d3f2a6174b398a0cb0b1b4821147c87f8d7cf7e2422740d0e90340becb3c975
7
- data.tar.gz: 879406bcfb5e904c51c502b2fb5cd91540487993dcb5c33fa0ef8b0104c78ca8a6ba6aa37e0e577a8fd2effbb167b233d5497820849eaef9050b8774a6f3974d
6
+ metadata.gz: 3e72653b6788186e5e567e5a773510877d33e8b5880a09ecbd4c65c3ae9d06b9614553797fc9c1563f343925b6707abc9db278360a5000843f66f118c0e19502
7
+ data.tar.gz: ae2d68559f60e8da03e82e63613698a98da071f216e703a8dcfab80839f486abc0881936f390299ebc010ec62d29a2b355e46bdaf82ec9c998c4f3a1c0d9e9bd
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Seyithan
3
+ Copyright (c) 2024 Seyithan Teymur (https://seyithan.me)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,39 +1,87 @@
1
1
  # CoreMerchant
2
2
 
3
- ## This gem is under development at pre-release stage
3
+ > [!CAUTION]
4
+ > This gem is under development at pre-release stage
4
5
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/core_merchant`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ CoreMerchant is a library for customer, product, and subscription management in Rails applications. It's meant to be a starting point for building e-commerce and SaaS applications. It provides essential functionality for handling customers, products, and subscriptions. Does not include payment integrations.
6
7
 
7
- TODO: Delete this and the text above, and describe your gem
8
+ ## To-dos until 1.0.0 release
9
+ - [X] Add customer behavior
10
+ - [X] Add initializer generator
11
+ - [X] Add SubscriptionPlan model
12
+ - [ ] Add Subscription model
13
+ - [ ] Add subscription management service
14
+ - [ ] Add sidekiq jobs for subscription management
15
+ - [ ] Add Invoice model
16
+ - [ ] Add billing and invoicing service
8
17
 
9
18
  ## Installation
19
+ Add this line to your application's Gemfile:
20
+ ```
21
+ gem 'core_merchant', '~> 0.1.0'
22
+ ```
23
+ and run `bundle install`.
10
24
 
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add core_merchant
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install core_merchant
25
+ Alternatively, you can install the gem manually:
26
+ ```
27
+ $ gem install core_merchant
28
+ ```
18
29
 
19
30
  ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+ ### Initialization
32
+ Run the generator to create the initializer file and the migrations:
33
+ ```
34
+ $ rails generate core_merchant:install
35
+ ```
36
+ This will create the following files:
37
+ - `config/initializers/core_merchant.rb` - Configuration file
38
+ - `db/migrate/xxxxxx_create_core_merchant_subscription_plans.rb` - Migration for subscription plans
39
+
40
+ You can then run the migrations:
41
+ ```
42
+ $ rails db:migrate
43
+ ```
44
+
45
+ ### Configuration
46
+ The initializer file `config/initializers/core_merchant.rb` contains the following configuration options:
47
+ ```ruby
48
+ config.customer_class
49
+ ```
50
+
51
+ ### The cusomer class
52
+ The customer class is the model that represents the customer in your application. For example, if you already have a `User` model that represents the users of your application, you can use it as the customer class in CoreMerchant. To do this, you need to set the `customer_class` configuration option in the initializer file:
53
+ ```ruby
54
+ # config/initializers/core_merchant.rb
55
+ CoreMerchant.configure do |config|
56
+ config.customer_class = 'User'
57
+ end
58
+ ```
59
+
60
+ You need to then include the `CoreMerchant::Customer` module in the customer class:
61
+ ```ruby
62
+ # app/models/user.rb
63
+ class User < ApplicationRecord
64
+ include CoreMerchant::Customer
65
+
66
+ # ... the rest of your model code
67
+ end
68
+ ```
69
+
70
+ ## Models
71
+ ### SubscriptionPlan
72
+ The `SubscriptionPlan` model represents a subscription plan in your application. It has the following attributes:
73
+ - `name_key`: A unique key for the subscription plan.
74
+ This key is used to identify the plan in the application,
75
+ as well as the translation key for the plan name through `core_merchant.subscription_plans`.
76
+ - `price_cents`: The price of the subscription plan in cents.
77
+ - `duration`: The duration of the subscription plan.
78
+ Consists of a number and a letter representing the time unit as day, week, month, or year.
79
+ For example, `1w` for 1 week, `3m` for 3 months, `1y` for 1 year.
80
+ - `introductory_price_cents`: The introductory price of the subscription plan in cents.
81
+ - `introductory_duration`: The duration of the introductory price of the subscription plan.
82
+
83
+ > [!NOTE]
84
+ > Other models and features are being developed and will be added in future releases.
28
85
 
29
86
  ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/core_merchant. 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/[USERNAME]/core_merchant/blob/main/CODE_OF_CONDUCT.md).
32
-
33
- ## License
34
-
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
-
37
- ## Code of Conduct
38
-
39
- Everyone interacting in the CoreMerchant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/core_merchant/blob/main/CODE_OF_CONDUCT.md).
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/theseyithan/core_merchant
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoreMerchant
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -21,7 +21,7 @@ module CoreMerchant
21
21
  def create_migration_file
22
22
  timestamp = self.class.next_migration_number(nil)
23
23
  migration_template "create_core_merchant_subscription_plans.rb",
24
- "db/migrate/#{timestamp}_create_core_merchant_subscription_plans.rb"
24
+ "db/migrate/create_core_merchant_subscription_plans.rb"
25
25
  end
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seyithan Teymur